Package no.digipost.concurrent
Class CountDown
java.lang.Object
no.digipost.concurrent.CountDown
- All Implemented Interfaces:
TargetState
A count down implementation of
TargetState,
which will count the invocations of yet() and
return true after a given amount of invocations.
The implementation is thread-safe in the sense that it is guaranteed
that yet() will return false an exact amount
of times, regardless of different threads invoking yet(),
before switching to only return true.
This can often serve for testing purposes where you would
like a controlled amount of queries to a TargetState,
before it changes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface no.digipost.concurrent.TargetState
TargetState.TaskControl -
Field Summary
Fields inherited from interface no.digipost.concurrent.TargetState
IMMEDIATELY, NEVER -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface no.digipost.concurrent.TargetState
or, untilThen, untilThen
-
Constructor Details
-
CountDown
public CountDown(long count) Create a new count down from the given startcount.- Parameters:
count- the number of invocations whereyet()will indicate the count down is not finished yet, i.e. the number of timesyet()will returnfalse, and switches to only returntrue.
-
-
Method Details
-
yet
public boolean yet()Description copied from interface:TargetStateTell if the target state has been reached yet. Once this method returnstrue, it will never returnfalseagain.- Specified by:
yetin interfaceTargetState- Returns:
truewhen the target state has been reached,falseotherwise.
-
toString
-