public void processQueue ( Predicate < RequestHandler > handlerConsumer , Prioritizer prioritizer ) { Comparator < RequestHandler > comparator = prioritizer == null ? Ordering . allEqual ( ) :: compare : ( a , b ) -> prioritizer . compareTo ( a . getRequest ( ) . getDesiredCapabilities ( ) , b . getRequest ( ) . getDesiredCapabilities ( ) ) ; lock . writeLock ( ) . lock ( ) ; try { newSessionRequests . stream ( ) . sorted ( comparator ) . filter ( handlerConsumer ) . forEach ( requestHandler -> { if ( ! removeNewSessionRequest ( requestHandler ) ) { log . severe ( "Bug removing request " + requestHandler ) ; } } ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } }
Processes all the entries in this queue .