@ Override public final N peek ( ) { // read the current cursor int spin = 0 ; for ( ; ; ) { final long readLock = seqLock . readLock ( ) ; final int stackTop = this . stackTop . get ( ) ; if ( stackTop > 0 ) { final N n = stack . get ( stackTop - 1 ) ; if ( seqLock . readLockHeld ( readLock ) ) { return n ; } // else loop again } else { return null ; } spin = Condition . progressiveYield ( spin ) ; } }
peek at the top of the stack