org.mentaqueue.wait
Class SpinYieldParkWaitStrategy

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

public class SpinYieldParkWaitStrategy
extends Object
implements WaitStrategy

This wait strategy first busy spinings, then yields, then sleep. You can configure each component by passing a spinCount and yieldCount. It optionally supports backing-off for the LockSupport.parkNanos method, increasing the sleep time by one nanosecond until the reset method is called.

Author:
Sergio Oliveira Jr.

Constructor Summary
SpinYieldParkWaitStrategy()
           
SpinYieldParkWaitStrategy(boolean parkBackOff)
           
SpinYieldParkWaitStrategy(int spinCount, int yieldCount)
           
SpinYieldParkWaitStrategy(int spinCount, 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

SpinYieldParkWaitStrategy

public SpinYieldParkWaitStrategy(int spinCount,
                                 int yieldCount,
                                 boolean parkBackOff)

SpinYieldParkWaitStrategy

public SpinYieldParkWaitStrategy(boolean parkBackOff)

SpinYieldParkWaitStrategy

public SpinYieldParkWaitStrategy(int spinCount,
                                 int yieldCount)

SpinYieldParkWaitStrategy

public SpinYieldParkWaitStrategy()
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.