8 releases
0.3.4 | Jun 26, 2024 |
---|---|
0.3.3 | Jun 26, 2024 |
0.3.1 | Oct 15, 2023 |
0.2.3 | Jul 25, 2023 |
0.1.2 | Apr 19, 2023 |
#1242 in Rust patterns
399 downloads per month
62KB
1.5K
SLoC
sod-mpsc
sod::Service
implementations to interact with std::sync::mpsc
queues.
Service Impls
MpscSender
sends to astd::sync::mpsc::channel
.MpscSyncSender
sends to astd::sync::mpsc::sync_channel
and blocks if the channel is full.MpscSyncTrySender
tries to send to astd::sync::mpsc::sync_channel
and is able to be retried viasod::RetryService
when the channel is full.MpscReceiver
receives from astd::sync::mpsc::channel
orstd::sync::mpsc::sync_channel
, blocking until an element is received.MpscTryReceiver
tries to receive from astd::sync::mpsc::channel
orstd::sync::mpsc::sync_channel
, and is able to be retried viasod::Retryable
when the channel is empty.
Example
use sod::Service;
use sod_mpsc::{MpscSender, MpscReceiver};
use std::sync::mpsc;
let (tx, rx) = mpsc::channel();
let pusher = MpscSender::new(tx);
let poller = MpscReceiver::new(rx);
pusher.process(1).unwrap();
pusher.process(2).unwrap();
assert_eq!(poller.process(()).unwrap(), 1);
assert_eq!(poller.process(()).unwrap(), 2);
Dependencies
~205–650KB
~15K SLoC