

Sender in std::sync::mpsc - Rust
source link: https://doc.rust-lang.org/stable/std/sync/mpsc/struct.Sender.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

The sending-half of Rust’s asynchronous channel
type. This half can only be
owned by one thread, but it can be cloned to send to other threads.
Messages can be sent through this channel with send
.
Note: all senders (the original and the clones) need to be dropped for the receiver
to stop blocking to receive messages with Receiver::recv
.
Examples
use std::sync::mpsc::channel;
use std::thread;
let (sender, receiver) = channel();
let sender2 = sender.clone();
// First thread owns sender
thread::spawn(move || {
sender.send(1).unwrap();
});
// Second thread owns sender2
thread::spawn(move || {
sender2.send(2).unwrap();
});
let msg = receiver.recv().unwrap();
let msg2 = receiver.recv().unwrap();
assert_eq!(3, msg + msg2);
RunRecommend
-
7
1.0.0[−][src]Module std::result[−]Er...
-
13
Variants Ready(T)[−]Represents that a value is immediately ready. Pending[−]Represents that a value is not read...
-
6
Struct std::sync::Arc1.0.0[−]
-
8
Struct std::sync::Once1.0.0[−]
-
12
Struct std::sync::OnceState1.51.0
-
8
[−]Useful synchronization primitives. The need for synchronization Conceptually, a Rust program is a series of operatio...
-
7
impl AtomicBool[src]pub const fn
-
9
Hollywood MPSC Platform Awarded First Nugenesis Nuchain Slot – CryptoMode Search NuGenesis Signs major contract to deliver on much discussed, Hollywood MPSC Platform (Mult...
-
14
Some thoughts on the std::execution proposal and my understanding of the underlying theory. What’s proposed From the paper’s
-
7
Conversation Contributor...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK