/** * Signal the completion of an event. The value passed to this * method must be the same as the return value previously obtained * from the startEvent method. This method will signal the * completion of all pending barriers that were completed by the * completion of this event. * * @param token Opaque token identifying the completed event. */ public void completeEvent(int token) { if (token == this.barrierToken) { --eventCount; return; } --queue.get(queue.size() - (this.barrierToken - token)).eventCount; while (!queue.isEmpty() && queue.get(0).eventCount == 0) { queue.remove(0).handler.completeBarrier(); } }