fn chan
Creates a channel; cap: 0 is a rendezvous channel (§8.7).
Example:
fn main() io {
let (tx, rx) = chan<str>(cap: 4)
tx.send("a")!
tx.send("b")!
print("{rx.recv()!}{rx.recv()!}")
}Output
ab
@intrinsic("chan") pub(api) fn chan<T>(cap: usize = 0) -> (Sender<T>, Receiver<T>)Complexity. O(1).
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
cap | usize = 0 |
Returns
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/task.oxl:66