private void tryRunNext ( ) { while ( runningSemaphore . tryAcquire ( ) ) { ExecutionTask execution = queue . poll ( ) ; if ( execution != null ) { // Note: we've removed the execution from the queue so we're committed to running it // if we fail to do so for any reason, we need to call the exception handler to fail the execution try { execution . submit ( ) ; } catch ( Throwable e ) { // Any exception here is unexpected runningSemaphore . release ( ) ; execution . exceptionHandler . handle ( e ) ; } } else { runningSemaphore . release ( ) ; break ; } } }
Attempt to run any queued executions