Future

Inherits from: Object

A Future represents a pending asynchronous result from a remote operation. Created by RemoteProcess>>asyncSend:with:.

Use await to block until the result is available. Use isResolved to check without blocking. Use result to get the value if resolved.

Example
| future <Future> result <Integer> |
future := worker asyncSend: #compute: with: 42.
future isResolved       "=> false (initially)"
result := future await. "=> blocks until resolved"
future isResolved       "=> true"

Instance Methods

uncategorized

await

Block the current process until the Future resolves. Returns the result value. If the remote side returned an error, returns nil (check error for the error message).

Example
future await    "=> the result value"
await:

Block for at most ms milliseconds. Returns the result value if resolved in time, or nil on timeout.

Example
future await: 5000    "=> result or nil"
error

Return the error message string if the Future resolved with an error, or nil if successful or still pending.

isResolved

Return true if the Future has been resolved (success or error).

Example
future isResolved    "=> true/false"
printString

Return a string representation.

result

Return the result value if resolved, or nil if still pending. Does not block.