Package org.apache.flink.core.testutils
Class OneShotLatch
java.lang.Object
org.apache.flink.core.testutils.OneShotLatch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Waits untiltrigger()is called.voidWaits untiltrigger()is called.voidvoidawaitQuietly(long timeout, TimeUnit timeUnit) Callsawait(long, TimeUnit)and transforms anyInterruptedExceptionorTimeoutExceptioninto aRuntimeException.intbooleanChecks if the latch was triggered.voidreset()Resets the latch so thatisTriggered()returns false.toString()voidtrigger()Fires the latch.
-
Constructor Details
-
OneShotLatch
public OneShotLatch()
-
-
Method Details
-
trigger
public void trigger()Fires the latch. Code that is blocked onawait()will now return. -
await
Waits untiltrigger()is called. Oncetrigger()has been called this call will always return immediately.- Throws:
InterruptedException- Thrown if the thread is interrupted while waiting.
-
awaitQuietly
public void awaitQuietly() -
await
Waits untiltrigger()is called. Once#trigger()has been called this call will always return immediately.If the latch is not triggered within the given timeout, a
TimeoutExceptionwill be thrown after the timeout.A timeout value of zero means infinite timeout and make this equivalent to
await().- Parameters:
timeout- The value of the timeout, a value of zero indicating infinite timeout.timeUnit- The unit of the timeout- Throws:
InterruptedException- Thrown if the thread is interrupted while waiting.TimeoutException- Thrown, if the latch is not triggered within the timeout time.
-
awaitQuietly
Callsawait(long, TimeUnit)and transforms anyInterruptedExceptionorTimeoutExceptioninto aRuntimeException. -
isTriggered
public boolean isTriggered()Checks if the latch was triggered.- Returns:
- True, if the latch was triggered, false if not.
-
getWaitersCount
public int getWaitersCount() -
reset
public void reset()Resets the latch so thatisTriggered()returns false. -
toString
-