const classafConcurrent::Synchronized

sys::Obj
  afConcurrent::Synchronized

Provides synchronized access to blocks of code. Example usage:

lock := Synchronized(ActorPool())

val := synchronized |->Obj?| {
    // ...
    // important stuff
    // ...
    return 69
}
async

Source

Future async(|->Obj? f)

Runs the given func asynchronously, using this Synchronized's ActorPool.

Errs that occur within the block are logged but not rethrown unless you call get() on the returned Future.

The given func and return value must be immutable.

make

Source

new make(ActorPool actorPool, Duration? timeout := null)

Create a Synchronized class that uses the given ActorPool and timeout.

synchronized

Source

Obj? synchronized(|->Obj? f)

This effectively wraps the given func in a Java synchronized { ... } block and returns its calculated value.

The given func and return value must be immutable.

timeout

Source

const Duration? timeout

The default timeout to use when waiting for synchronized blocks to complete.