public void finallyDo ( Callback resultCB ) { // FIXME: this can be implemented more efficient while ( ! lock . compareAndSet ( false , true ) ) { } try { if ( resultReceiver != null ) throw new RuntimeException ( "Double register of future listener" ) ; resultReceiver = resultCB ; if ( hadResult ) { hasFired = true ; lock . set ( false ) ; resultCB . complete ( result , error ) ; } } finally { lock . set ( false ) ; } }
same as then but avoid creation of new promise