public void queue ( final AsyncEvent < K > _event ) { final K key = _event . getKey ( ) ; synchronized ( getLockObject ( key ) ) { Queue < AsyncEvent < K >> q = keyQueue . get ( key ) ; if ( q != null ) { q . add ( _event ) ; return ; } q = new LinkedList < AsyncEvent < K > > ( ) ; keyQueue . put ( key , q ) ; } Runnable r = new Runnable ( ) { @ Override public void run ( ) { runMoreOrStop ( _event ) ; } } ; executor . execute ( r ) ; }
Immediately executes an event with the provided executor . If an event is already executing for the identical key queue the event and execute the event with FIFO scheme preserving the order of the arrival .