com.kuka.common.concurrent
Class SetResetBarrier

java.lang.Object
  extended by com.kuka.common.concurrent.SetResetBarrier

public final class SetResetBarrier
extends Object

A synchronization aid that keeps two states, each of which can be waited upon.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

Constructor Summary
SetResetBarrier()
          Creates a new set-reset barrier with a default "reset" state.
SetResetBarrier(boolean initialState)
          Creates a new set-reset barrier with the given initial state.
 
Method Summary
 boolean compareAndSet(boolean expect, boolean update)
          Atomically sets the value to the given updated value if the current value == the expected value.
 IWaitToken getResetToken()
          Returns the wait token for the "reset" state.
 IWaitToken getSetToken()
          Returns the wait token for the "set" state.
 boolean isSet()
          Return true if the state is "set", false if the state is "reset".
 void reset()
          Sets the state of the barrier to "reset".
 void set()
          Sets the state of the barrier to "set".
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SetResetBarrier

public SetResetBarrier()
Creates a new set-reset barrier with a default "reset" state.


SetResetBarrier

public SetResetBarrier(boolean initialState)
Creates a new set-reset barrier with the given initial state.

Parameters:
initialState - the initial state, true - if set.
Method Detail

set

public void set()
Sets the state of the barrier to "set". If the state is already "set" nothing happens.


reset

public void reset()
Sets the state of the barrier to "reset". If the state is already "reset" nothing happens.


isSet

public boolean isSet()
Return true if the state is "set", false if the state is "reset".

Returns:
true if "set", false if "reset"

compareAndSet

public boolean compareAndSet(boolean expect,
                             boolean update)
Atomically sets the value to the given updated value if the current value == the expected value.

Parameters:
expect - the expected value
update - the new value
Returns:
true if successful. False return indicates that the actual value was not equal to the expected value.

getSetToken

public IWaitToken getSetToken()
Returns the wait token for the "set" state. Note that by the time the waiting thread is released the state could already have been altered.

Returns:
the wait token

getResetToken

public IWaitToken getResetToken()
Returns the wait token for the "reset" state. Note that by the time the waiting thread is released the state could already have been altered.

Returns:
the wait token

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2019. All rights reserved.