java.lang.Object
swim.concurrent.Sync<T>
- All Implemented Interfaces:
ForkJoinPool.ManagedBlocker
,Cont<T>
A
Cont
inuation whose completion can be synchronously awaited. A
Sync
continuation is used to await the completion of an asynchronous
operation.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionawait()
Waits an unbounded amount of time for thisSync
continuation to complete.await
(long timeout) Waits a maximum oftimeout
milliseconds for thisSync
continuation to complete.void
Invoked when the asynchronous operation completes with avalue
.boolean
block()
boolean
void
Invoked when the asynchronous operation fails with anerror
.
-
Constructor Details
-
Sync
public Sync()Constructs a newSync
continuation that awaits a value of typeT
.
-
-
Method Details
-
isReleasable
public boolean isReleasable()- Specified by:
isReleasable
in interfaceForkJoinPool.ManagedBlocker
-
block
- Specified by:
block
in interfaceForkJoinPool.ManagedBlocker
- Throws:
InterruptedException
-
bind
Description copied from interface:Cont
Invoked when the asynchronous operation completes with avalue
. -
trap
Description copied from interface:Cont
Invoked when the asynchronous operation fails with anerror
. -
await
Waits a maximum oftimeout
milliseconds for thisSync
continuation to complete. Performs a managed block to avoid thread starvation while waiting.- Throws:
SyncException
- if thetimeout
milliseconds elapses and thisSync
continuation still hasn't been completed.InterruptedException
-
await
Waits an unbounded amount of time for thisSync
continuation to complete. Performs a managed block to avoid thread starvation while waiting.- Throws:
InterruptedException
-