Package hudson.util
Class OneShotEvent
- java.lang.Object
-
- hudson.util.OneShotEvent
-
public final class OneShotEvent extends Object
Concurrency primitive.A
OneShotEvent
is like a pandora's box. It starts with the closed (non-signaled) state. Multiple threads can wait for the event to become the signaled state.Once the event becomes signaled, or the pandora's box is opened, every thread gets through freely, and there's no way to turn it back off.
- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description OneShotEvent()
OneShotEvent(Object lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
block()
Blocks until the event becomes the signaled state.void
block(long timeout)
Blocks until the event becomes the signaled state.boolean
isSignaled()
Returns true if a value is offered.void
signal()
Non-blocking method that signals this event.
-
-
-
Constructor Detail
-
OneShotEvent
public OneShotEvent()
-
OneShotEvent
public OneShotEvent(Object lock)
-
-
Method Detail
-
signal
public void signal()
Non-blocking method that signals this event.
-
block
public void block() throws InterruptedException
Blocks until the event becomes the signaled state.This method blocks infinitely until a value is offered.
- Throws:
InterruptedException
-
block
public void block(long timeout) throws InterruptedException
Blocks until the event becomes the signaled state.If the specified amount of time elapses, this method returns null even if the value isn't offered.
- Throws:
InterruptedException
-
isSignaled
public boolean isSignaled()
Returns true if a value is offered.
-
-