Sender
class Sender Import
Source: use thread::{Sender}; compiler/src/builtin_docs/thread.hy The sending half of a channel made by channel.
Sender handles can be passed to spawn (alone or inside tuples, arrays,
records and class instances): every copy refers to the same channel.
close on any copy closes the channel for everyone.
Examples#
use thread::{channel, send, recv, Sender, Receiver};
use tests::assert;
let (tx, rx) = match channel() {
Result::Ok(pair) => pair,
Result::Err(_) => panic "channel failed",
};
let s: Sender = tx;
let r: Receiver = rx;
let _ = send(s, "hi");
let got = match recv(r) {
Result::Ok(v) => v,
Result::Err(_) => "",
};
assert!(got == "hi");
See also#
thread::channelthread::spawnthread::closeThread: A handle to a function running on another OS thread, fromspawn.Receiver: The receiving half of a channel made bychannel.Mutex: A mutual-exclusion lock that owns a value, made bymutex.RwLock: A readers-writer lock that owns a value, made byrwlock.