Types
struct Isolate#
std.isolate worker handle.
_handle: int |
|---|
Functions
Starts an isolate entry point with copied arguments.
entry: Name of the entry-point function to run in the new isolate.args: Arguments copied across the isolate boundary.
fn double(value: int) -> int { value * 2 }
fn main() {
let worker = std.isolate.spawn("double", [21])
println(std.isolate.join(worker)) // 42
}Waits for an isolate and returns its result.
isolate: Isolate to wait for.
extern fn channel(capacity: int) -> int#
Creates an isolate channel and returns its identifier.
capacity: Buffered slots the isolate channel holds.
fn producer(channel: int) -> int {
std.isolate.send(channel, "moon")
std.isolate.close(channel)
1
}
fn main() {
let channel = std.isolate.channel(1)
let worker = std.isolate.spawn("producer", [channel])
println(std.isolate.recv<string>(channel).unwrap())
println(std.isolate.recv<string>(channel).is_none())
println(std.isolate.join(worker))
}extern fn send<T>(channel: int, value: T) -> bool#
extern fn close(channel: int)#