# PicoPub
A synchronous pub-sub library built on Mutex and Condvar,
with per-subscriber bounded queues and configurable backpressure.
## Features
- Sync/Async runtime
- No channels
- Per-subscriber backpressure
- Zero-copy fan-out using Arc<T>
## Non-goals
- Lock-free algorithms
- Network transport
## Example
```rust
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());
```