| Crates.io | picopub |
| lib.rs | picopub |
| version | 0.1.1 |
| created_at | 2026-01-14 18:38:23.862507+00 |
| updated_at | 2026-01-14 18:43:46.513296+00 |
| description | A sync/async pub-sub library with bounded queues and backpressure using Mutex and Condvar |
| homepage | |
| repository | https://github.com/alejandro-llanes/picopub |
| max_upload_size | |
| id | 2043429 |
| size | 33,831 |
A synchronous pub-sub library built on Mutex and Condvar, with per-subscriber bounded queues and configurable backpressure.
use picopub::PicoPub;
let ps = PicoPub::<String, u32>::new();
let sub = ps.subscribe(String::from("counters"), Some(2)).await;
let nums = vec![1, 1];
let _ = tokio::join!({
let nums = nums.clone();
spawn(async move {
for n in nums.iter() {
ps.publish(String::from("counters"), n + 1).await;
}
})
});
let mut stream = sub.stream();
let n1 = stream.next().await.expect("early");
let n2 = stream.next().await.expect("early");
assert_eq!(n1, (nums[0] + 1).into());
assert_eq!(n2, (nums[1] + 1).into());