Documentation for method start
Documentation for method start, assembled from the following types:
method start(Proc::Async: : = , : = --> Promise)
Initiates spawning of the external program. Returns a promise that will be kept with a Proc object once the external program exits, and that will be broken if the program cannot be started.
start is called on a Proc::Async object on which it has already been called before, an exception of type X::Proc::Async::AlreadyStarted is thrown.
Note: If you wish to
await the Promise and discard its result, using
try await .start;
will throw if the program exited with non-zero status, as the
Proc returned as the result of the Promise throws when sunk and in this case it will get sunk outside the
try. To avoid that, sink it yourself inside the
try sink await .start;
method start(Promise: , : = --> Promise)
Creates a new Promise that runs the given code object. The promise will be kept when the code terminates normally, or broken if it throws an exception. The return value or exception can be inspected with the
The scheduler that handles this promise can be passed as a named argument.
There is also a statement prefix
start that provides syntactic sugar for this method:
# these two are equivalent:my = Promise.start();my = start ;
method start(Supply: --> Supply)
Creates a supply of supplies. For each value in the original supply, the code object is scheduled on another thread, and returns a supply either of a single value (if the code succeeds), or one that quits without a value (if the code fails).
This is useful for asynchronously starting work that you don't block on.
migrate to join the values into a single supply again.
method start(Thread: , Bool : = False, Str : = '<anon>' --> Thread)
Creates, runs and returns a new
Thread. Note that it can (and often does) return before the thread's code has finished running.