private boolean selfAssign ( ) { // if we aren't permitted to assign in this state, fail if ( ! get ( ) . canAssign ( true ) ) return false ; for ( SEPExecutor exec : pool . executors ) { if ( exec . takeWorkPermit ( true ) ) { Work work = new Work ( exec ) ; // we successfully started work on this executor, so we must either assign it to ourselves or ... if ( assign ( work , true ) ) return true ; // ... if we fail, schedule it to another worker pool . schedule ( work ) ; // and return success as we must have already been assigned a task assert get ( ) . assigned != null ; return true ; } } return false ; }
try to assign ourselves an executor with work available