Logo Search packages:      
Sourcecode: scala version File versions  Download package

FJTask scala::actors::FJTaskRunner::confirmTake ( int  oldBase  )  [inline, protected]

double-check a potential take

Definition at line 545 of file FJTaskRunner.java.

References barrier, base, deq, and top.

Referenced by take().

                                            {

    /*
      Use a second (guaranteed uncontended) synch
      to serve as a barrier in case JVM does not
      properly process read-after-write of 2 volatiles
    */

    synchronized(barrier) {
      if (oldBase < top) {
        /*
          We cannot call deq[oldBase].take here because of possible races when
          nulling out versus concurrent push operations.  Resulting
          accumulated garbage is swept out periodically in
          checkOverflow, or more typically, just by keeping indices
          zero-based when found to be empty in pop, which keeps active
          region small and constantly overwritten. 
        */
        
        return deq[oldBase & (deq.length-1)].get();
      }
      else {
        base = oldBase;
        return null;
      }
    }
  }


Generated by  Doxygen 1.6.0   Back to index