/** * Release the latch, thereby unblocking all current and future calls to {@link #await()}. */ public void release() { // Once the release sentinel is on the stack, it can never (observably) leave. // Waiters might accidentally remove the released sentinel from the stack for brief periods of time, but then // they are required to fix the situation and put it back. // Atomically swapping the release sentinel onto the stack will give us back all the waiters, if any. Node waiters = (Node) UnsafeUtil.getAndSetObject( this, stackOffset, released ); if ( waiters == null ) { // There are no waiters to unpark, so don't bother. return; } unparkSuccessor( waiters ); }
/** * Release the latch, thereby unblocking all current and future calls to {@link #await()}. */ public void release() { // Once the release sentinel is on the stack, it can never (observably) leave. // Waiters might accidentally remove the released sentinel from the stack for brief periods of time, but then // they are required to fix the situation and put it back. // Atomically swapping the release sentinel onto the stack will give us back all the waiters, if any. Node waiters = (Node) UnsafeUtil.getAndSetObject( this, stackOffset, released ); if ( waiters == null ) { // There are no waiters to unpark, so don't bother. return; } unparkSuccessor( waiters ); }