public class BlockingCell<T> extends Object
Constructor and Description |
---|
BlockingCell()
Instantiate a new BlockingCell waiting for a value of the specified type.
|
Modifier and Type | Method and Description |
---|---|
T |
get()
Wait for a value, and when one arrives, return it (without clearing it).
|
T |
get(long timeout)
Wait for a value, and when one arrives, return it (without clearing it).
|
void |
set(T newValue)
Store a value in this BlockingCell, throwing
IllegalStateException if the cell already has a value. |
boolean |
setIfUnset(T newValue)
Store a value in this BlockingCell if it doesn't already have a value.
|
T |
uninterruptibleGet()
As get(), but catches and ignores InterruptedException, retrying until a value appears.
|
T |
uninterruptibleGet(int timeout)
As get(long timeout), but catches and ignores InterruptedException, retrying until
a value appears or until specified timeout is reached.
|
public BlockingCell()
public T get() throws InterruptedException
InterruptedException
- if this thread is interruptedpublic T get(long timeout) throws InterruptedException, TimeoutException
timeout
- timeout in milliseconds. -1 effectively means infinityInterruptedException
- if this thread is interruptedTimeoutException
public T uninterruptibleGet()
public T uninterruptibleGet(int timeout) throws TimeoutException
timeout
- timeout in milliseconds. -1 means 'infinity': never time outTimeoutException
public void set(T newValue)
IllegalStateException
if the cell already has a value.newValue
- the new value to storepublic boolean setIfUnset(T newValue)
newValue
- the new value to storeCopyright © 2022 VMware, Inc. or its affiliates.. All rights reserved.