- java.lang.Object
-
- swim.concurrent.Sync<T>
-
- All Implemented Interfaces:
ForkJoinPool.ManagedBlocker,Cont<T>
public class Sync<T> extends Object implements Cont<T>, ForkJoinPool.ManagedBlocker
AContinuation whose completion can be synchronously awaited. ASynccontinuation is used to await the completion of an asynchronous operation.
-
-
Constructor Summary
Constructors Constructor Description Sync()Constructs a newSynccontinuation that awaits a value of typeT.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tawait()Waits an unbounded amount of time for thisSynccontinuation to complete.Tawait(long timeout)Waits a maximum oftimeoutmilliseconds for thisSynccontinuation to complete.voidbind(T value)Invoked when the asynchronous operation completes with avalue.booleanblock()booleanisReleasable()voidtrap(Throwable error)Invoked when the asynchronous operation fails with anerror.
-
-
-
Method Detail
-
isReleasable
public boolean isReleasable()
- Specified by:
isReleasablein interfaceForkJoinPool.ManagedBlocker
-
block
public boolean block() throws InterruptedException- Specified by:
blockin interfaceForkJoinPool.ManagedBlocker- Throws:
InterruptedException
-
bind
public void bind(T value)
Description copied from interface:ContInvoked when the asynchronous operation completes with avalue.
-
trap
public void trap(Throwable error)
Description copied from interface:ContInvoked when the asynchronous operation fails with anerror.
-
await
public T await(long timeout) throws InterruptedException
Waits a maximum oftimeoutmilliseconds for thisSynccontinuation to complete. Performs a managed block to avoid thread starvation while waiting.- Throws:
SyncException- if thetimeoutmilliseconds elapses and thisSynccontinuation still hasn't been completed.InterruptedException
-
await
public T await() throws InterruptedException
Waits an unbounded amount of time for thisSynccontinuation to complete. Performs a managed block to avoid thread starvation while waiting.- Throws:
InterruptedException
-
-