private int acquireExpedite ( ) { int a ; while ( ( a = expeditesAvailable . get ( ) ) > 0 && ! expeditesAvailable . compareAndSet ( a , a - 1 ) ) ; return a ; // returning the value rather than true/false will enable better debug }
Attempt to acquire a permit to expedite which involves decrementing the available expedites . Only allow decrement of a positive value and otherwise indicate there are no available expedites .