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

final FJTask scala::actors::FJTaskRunner::pop (  )  [inline, protected]

Return a popped task, or null if DEQ is empty. Called ONLY by current thread.

This is not usually called directly but is instead inlined in callers. This version differs from the cilk algorithm in that pop does not fully back down and retry in the case of potential conflict with take. It simply rechecks under synch lock. This gives a preference for threads to run their own tasks, which seems to reduce flailing a bit when there are few tasks to run.

Definition at line 472 of file FJTaskRunner.java.

References base, confirmPop(), deq, take(), and top.

Referenced by coInvoke(), run(), taskJoin(), and taskYield().

       Decrement top, to force a contending take to back down.

    int t = --top;      

      To avoid problems with JVMs that do not properly implement
      read-after-write of a pair of volatiles, we conservatively
      grab without lock only if the DEQ appears to have at least two
      elements, thus guaranteeing that both a pop and take will succeed,
      even if the pre-increment in take is not seen by current thread.
      Otherwise we recheck under synch.

    if (base + 1 < t) 
      return deq[t & (deq.length-1)].take();
      return confirmPop(t);


Generated by  Doxygen 1.6.0   Back to index