final void externalPush ( ForkJoinTask < ? > task ) { int r ; // initialize caller's probe if ( ( r = ThreadLocalRandom . getProbe ( ) ) == 0 ) { ThreadLocalRandom . localInit ( ) ; r = ThreadLocalRandom . getProbe ( ) ; } for ( ; ; ) { WorkQueue q ; int wl , k , stat ; int rs = runState ; WorkQueue [ ] ws = workQueues ; if ( rs <= 0 || ws == null || ( wl = ws . length ) <= 0 ) tryInitialize ( true ) ; else if ( ( q = ws [ k = ( wl - 1 ) & r & SQMASK ] ) == null ) tryCreateExternalQueue ( k ) ; else if ( ( stat = q . sharedPush ( task ) ) < 0 ) break ; else if ( stat == 0 ) { signalWork ( ) ; break ; } else // move if busy r = ThreadLocalRandom . advanceProbe ( r ) ; } }
Adds the given task to a submission queue at submitter s current queue . Also performs secondary initialization upon the first submission of the first task to the pool and detects first submission by an external thread and creates a new shared queue if the one at index if empty or contended .