private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
private void flushPending() { // purge the pending inserts before doing anything else. This is potentially expensive. // Future versions may prefer to insert only a portion of the pending set, or // iterate it each time to determine the smallest (head) element. Set<Map.Entry<ReaperElement,ReaperElement>> entrySet = pendingInsertions.entrySet(); if(entrySet != null) { Iterator<Map.Entry<ReaperElement, ReaperElement>> queueIter = entrySet.iterator(); // iterator is weakly consistent - will traverse elements present at its time of creation, // may or may not see later updates. while(queueIter.hasNext()) { Map.Entry<ReaperElement,ReaperElement> entry = queueIter.next(); ReaperElement element = entry.getValue(); // insert/remove not locked, so we are careful to check that we don't insert // an element that has been removed from the pending set by a concurrent thread. if(entrySet.remove(entry)) { insertSorted(element); } } } } }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }
/** * @param reaperElement the reaper element to reorder in the sorted set. * @param delayMillis the amount of time to increment the element's timeout by. * @return the new soonest timeout in the set (not necessarily that of the reordered element) */ public synchronized long reorder(ReaperElement reaperElement, long delayMillis) { // assume it must be in the sorted list, as it was likely obtained via getFirst... removeSorted(reaperElement); // we could add delay to the original timeout, but using current time is probably safer. reaperElement.setAbsoluteTimeout((System.currentTimeMillis() + delayMillis)); // reinsert into its new position. insertSorted(reaperElement); // getFirst takes care of flushing the pending set for us. return getFirst().getAbsoluteTimeout(); }