org.mentaqueue.wait
Class YieldParkWaitStrategy

java.lang.Object
  extended by org.mentaqueue.wait.YieldParkWaitStrategy
All Implemented Interfaces:
WaitStrategy

public class YieldParkWaitStrategy
extends Object
implements WaitStrategy

No busy spinning, just yield and sleep. You can configure how many iteration to yield before sleeping. Supporing backing-off functionality, in other words, if turned on, the sleeping time will increase by one nanosecond gradually until reset is called.

Author:
Sergio Oliveira Jr.

Constructor Summary
YieldParkWaitStrategy()
           
YieldParkWaitStrategy(boolean parkBackOff)
           
YieldParkWaitStrategy(int yieldCount)
           
YieldParkWaitStrategy(int yieldCount, boolean parkBackOff)
           
 
Method Summary
 void reset()
          Reset the strategy because we have waited and we have accomplished what we were waiting for.
 void waitForOtherThread()
          Do something to wait: busy spinning, yield or sleep.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YieldParkWaitStrategy

public YieldParkWaitStrategy(int yieldCount,
                             boolean parkBackOff)

YieldParkWaitStrategy

public YieldParkWaitStrategy(int yieldCount)

YieldParkWaitStrategy

public YieldParkWaitStrategy(boolean parkBackOff)

YieldParkWaitStrategy

public YieldParkWaitStrategy()
Method Detail

waitForOtherThread

public final void waitForOtherThread()
Description copied from interface: WaitStrategy
Do something to wait: busy spinning, yield or sleep.

Specified by:
waitForOtherThread in interface WaitStrategy

reset

public final void reset()
Description copied from interface: WaitStrategy
Reset the strategy because we have waited and we have accomplished what we were waiting for.

Specified by:
reset in interface WaitStrategy


Copyright © 2012. All Rights Reserved.