/** * Hand in the object to share. */ public void handIn(String key, V obj) { if (!retrieveSharedQueue(key).offer(obj)) { throw new RuntimeException("Could not register the given element, broker slot is already occupied."); } }
private SuperstepBarrier initSuperstepBarrier() { SuperstepBarrier barrier = new SuperstepBarrier(getUserCodeClassLoader()); this.toSync.subscribeToEvent(barrier, AllWorkersDoneEvent.class); this.toSync.subscribeToEvent(barrier, TerminationEvent.class); return barrier; }
/** * the iteration head prepares the backchannel: it allocates memory, instantiates a {@link BlockingBackChannel} and * hands it to the iteration tail via a {@link Broker} singleton **/ private BlockingBackChannel initBackChannel() throws Exception { /* get the size of the memory available to the backchannel */ int backChannelMemoryPages = getMemoryManager().computeNumberOfPages(this.config.getRelativeBackChannelMemory()); /* allocate the memory available to the backchannel */ List<MemorySegment> segments = new ArrayList<MemorySegment>(); int segmentSize = getMemoryManager().getPageSize(); getMemoryManager().allocatePages(this, segments, backChannelMemoryPages); /* instantiate the backchannel */ BlockingBackChannel backChannel = new BlockingBackChannel(new SerializedUpdateBuffer(segments, segmentSize, getIOManager())); /* hand the backchannel over to the iteration tail */ Broker<BlockingBackChannel> broker = BlockingBackChannelBroker.instance(); broker.handIn(brokerKey(), backChannel); return backChannel; }
/** * The iteration head prepares the backchannel: it allocates memory, instantiates a {@link BlockingBackChannel} and * hands it to the iteration tail via a {@link Broker} singleton. **/ private BlockingBackChannel initBackChannel() throws Exception { /* get the size of the memory available to the backchannel */ int backChannelMemoryPages = getMemoryManager().computeNumberOfPages(this.config.getRelativeBackChannelMemory()); /* allocate the memory available to the backchannel */ List<MemorySegment> segments = new ArrayList<MemorySegment>(); int segmentSize = getMemoryManager().getPageSize(); getMemoryManager().allocatePages(this, segments, backChannelMemoryPages); /* instantiate the backchannel */ BlockingBackChannel backChannel = new BlockingBackChannel(new SerializedUpdateBuffer(segments, segmentSize, getIOManager())); /* hand the backchannel over to the iteration tail */ Broker<BlockingBackChannel> broker = BlockingBackChannelBroker.instance(); broker.handIn(brokerKey(), backChannel); return backChannel; }
/** * Hand in the object to share. */ public void handIn(String key, V obj) { if (!retrieveSharedQueue(key).offer(obj)) { throw new RuntimeException("Could not register the given element, broker slot is already occupied."); } }
/** * The iteration head prepares the backchannel: it allocates memory, instantiates a {@link BlockingBackChannel} and * hands it to the iteration tail via a {@link Broker} singleton. **/ private BlockingBackChannel initBackChannel() throws Exception { /* get the size of the memory available to the backchannel */ int backChannelMemoryPages = getMemoryManager().computeNumberOfPages(this.config.getRelativeBackChannelMemory()); /* allocate the memory available to the backchannel */ List<MemorySegment> segments = new ArrayList<MemorySegment>(); int segmentSize = getMemoryManager().getPageSize(); getMemoryManager().allocatePages(this, segments, backChannelMemoryPages); /* instantiate the backchannel */ BlockingBackChannel backChannel = new BlockingBackChannel(new SerializedUpdateBuffer(segments, segmentSize, getIOManager())); /* hand the backchannel over to the iteration tail */ Broker<BlockingBackChannel> broker = BlockingBackChannelBroker.instance(); broker.handIn(brokerKey(), backChannel); return backChannel; }
/** * hand in the object to share */ public void handIn(String key, V obj) { if (!retrieveSharedQueue(key).offer(obj)) { throw new RuntimeException("Could not register the given element, broker slot is already occupied."); } }
/** * The iteration head prepares the backchannel: it allocates memory, instantiates a {@link BlockingBackChannel} and * hands it to the iteration tail via a {@link Broker} singleton. **/ private BlockingBackChannel initBackChannel() throws Exception { /* get the size of the memory available to the backchannel */ int backChannelMemoryPages = getMemoryManager().computeNumberOfPages(this.config.getRelativeBackChannelMemory()); /* allocate the memory available to the backchannel */ List<MemorySegment> segments = new ArrayList<MemorySegment>(); int segmentSize = getMemoryManager().getPageSize(); getMemoryManager().allocatePages(this, segments, backChannelMemoryPages); /* instantiate the backchannel */ BlockingBackChannel backChannel = new BlockingBackChannel(new SerializedUpdateBuffer(segments, segmentSize, getIOManager())); /* hand the backchannel over to the iteration tail */ Broker<BlockingBackChannel> broker = BlockingBackChannelBroker.instance(); broker.handIn(brokerKey(), backChannel); return backChannel; }
/** * Hand in the object to share. */ public void handIn(String key, V obj) { if (!retrieveSharedQueue(key).offer(obj)) { throw new RuntimeException("Could not register the given element, broker slot is already occupied."); } }
/** blocking retrieval and removal of the object to share */ public V get(String key) { try { BlockingQueue<V> queue = retrieveSharedQueue(key); V objToShare = queue.take(); if (!queue.offer(objToShare)) { throw new RuntimeException("Error: Concurrent modification of the broker slot for key '" + key + "'."); } return objToShare; } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Blocking retrieval and removal of the object to share. */ public V get(String key) { try { BlockingQueue<V> queue = retrieveSharedQueue(key); V objToShare = queue.take(); if (!queue.offer(objToShare)) { throw new RuntimeException("Error: Concurrent modification of the broker slot for key '" + key + "'."); } return objToShare; } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** blocking retrieval and removal of the object to share */ public V getAndRemove(String key) { try { V objToShare = retrieveSharedQueue(key).take(); mediations.remove(key); return objToShare; } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Blocking retrieval and removal of the object to share. */ public V getAndRemove(String key) { try { V objToShare = retrieveSharedQueue(key).take(); mediations.remove(key); return objToShare; } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Blocking retrieval and removal of the object to share. */ public V getAndRemove(String key) { try { V objToShare = retrieveSharedQueue(key).take(); mediations.remove(key); return objToShare; } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Blocking retrieval and removal of the object to share. */ public V get(String key) { try { BlockingQueue<V> queue = retrieveSharedQueue(key); V objToShare = queue.take(); if (!queue.offer(objToShare)) { throw new RuntimeException("Error: Concurrent modification of the broker slot for key '" + key + "'."); } return objToShare; } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Blocking retrieval and removal of the object to share. */ public V get(String key) { try { BlockingQueue<V> queue = retrieveSharedQueue(key); V objToShare = queue.take(); if (!queue.offer(objToShare)) { throw new RuntimeException("Error: Concurrent modification of the broker slot for key '" + key + "'."); } return objToShare; } catch (InterruptedException e) { throw new RuntimeException(e); } }