public void unblockCancel ( CancelException event ) { ArrayList < AsyncWorkListener < T , TError > > listeners ; synchronized ( this ) { if ( unblocked ) return ; unblocked = true ; this . cancel = event ; if ( listenersInline == null ) { this . notifyAll ( ) ; return ; } listeners = listenersInline ; listenersInline = new ArrayList <> ( 2 ) ; } Logger log = LCCore . getApplication ( ) . getLoggerFactory ( ) . getLogger ( SynchronizationPoint . class ) ; while ( true ) { if ( ! log . debug ( ) ) for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) try { listeners . get ( i ) . cancelled ( event ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork: " + listeners . get ( i ) , t ) ; } else for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) { long start = System . nanoTime ( ) ; try { listeners . get ( i ) . cancelled ( event ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork: " + listeners . get ( i ) , t ) ; } long time = System . nanoTime ( ) - start ; if ( time > 1000000 ) // more than 1ms log . debug ( "Listener cancelled took " + ( time / 1000000.0d ) + "ms: " + listeners . get ( i ) ) ; } synchronized ( this ) { if ( listenersInline . isEmpty ( ) ) { listenersInline = null ; listeners = null ; this . notifyAll ( ) ; break ; } listeners . clear ( ) ; ArrayList < AsyncWorkListener < T , TError > > tmp = listeners ; listeners = listenersInline ; listenersInline = tmp ; } } }
Cancel this AsyncWork . Equivalent to the method cancel .