5 releases

0.3.1 Oct 15, 2023
0.2.4 Jul 25, 2023
0.2.3 Apr 20, 2023
0.2.2 Apr 20, 2023
0.2.1 Apr 20, 2023

#1963 in Rust patterns

Download history 13/week @ 2024-02-24 5/week @ 2024-03-09 6/week @ 2024-03-16 99/week @ 2024-03-23 3/week @ 2024-03-30

103 downloads per month

MIT/Apache

10KB
142 lines

sod-bus

sod::MutService implementations to interact with bus::Bus.

Service Impls

  • BusBroadcaster broadcasts to a bus::Bus and blocks until the operation is successful.
  • BusTryBroadcaster tries to broadcast to a bus::Bus and is able to be retried via sod::RetryService when the bus buffer is full.
  • BusReceiver receives from a bus::BusReader, blocking until an element is received.
  • BusTryReceiver tries to receive from a bus::BusReader and is able to be retried via sod::RetryService when the bus is empty.

Example

use sod::MutService;
use sod_bus::{BusBroadcaster, BusReceiver};

let mut broadcaster = BusBroadcaster::with_len(1024);
let mut receiver1 = broadcaster.create_receiver();
let mut receiver2 = broadcaster.create_receiver();

broadcaster.process(1).unwrap();
broadcaster.process(2).unwrap();
broadcaster.process(3).unwrap();

assert_eq!(receiver1.process(()).unwrap(), 1);
assert_eq!(receiver1.process(()).unwrap(), 2);
assert_eq!(receiver1.process(()).unwrap(), 3);

assert_eq!(receiver2.process(()).unwrap(), 1);
assert_eq!(receiver2.process(()).unwrap(), 2);
assert_eq!(receiver2.process(()).unwrap(), 3);

Dependencies

~0.8–6.5MB
~31K SLoC