Expand description
sod::Service implementations to interact with std::sync::mpsc queues.
§Service Impls
MpscSendersends to astd::sync::mpsc::channel.MpscSyncSendersends to astd::sync::mpsc::sync_channeland blocks if the channel is full.MpscSyncTrySendertries to send to astd::sync::mpsc::sync_channeland is able to be retried viasod::RetryServicewhen the channel is full.MpscReceiverreceives from astd::sync::mpsc::channelorstd::sync::mpsc::sync_channel, blocking until an element is received.MpscTryReceivertries to receive from astd::sync::mpsc::channelorstd::sync::mpsc::sync_channel, and is able to be retried viasod::RetryServicewhen 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);Structs§
- Mpsc
Receiver - A blocking
sod::Servicethat receives from an underlyingstd::sync::mpsc::Receiver, blocking per the rules ofReceiver::recv - Mpsc
Sender - A non-blocking
sod::Servicethat sends to an underlyingstd::sync::mpsc::Sender. - Mpsc
Sync Sender - A blocking
sod::Servicethat sends to an underlyingstd::sync::mpsc::SyncSenderusing thesendfunction. - Mpsc
Sync TrySender - A non-blocking
sod::Servicethat issod::Retryableand sends to an underlyingstd::sync::mpsc::SyncSenderusing thetry_sendfunction. - Mpsc
TryReceiver - A non-blocking
sod::Servicethat issod::Retryableand receives from an underlyingstd::sync::mpsc::Receiver, blocking per the rules ofReceiver::recv