| Category | Tokio | Crossbeam | Use Case | Optimization |
|----------|-------|-----------|----------|--------------|
| Channels | `mpsc`, `oneshot`, `broadcast`, `watch` | `unbounded`, `bounded` | Message passing between tasks/threads | Tokio: Async-aware, Crossbeam: Sync-optimized |
| Mutex | `tokio::sync::Mutex` | `parking_lot::Mutex` (via utils) | Exclusive access to shared data | Tokio: Async-aware, Crossbeam: Low-overhead |
| RwLock | `tokio::sync::RwLock` | `parking_lot::RwLock` (via utils) | Shared read / exclusive write access | Tokio: Async-aware, Crossbeam: Low-overhead |
| Semaphore | `tokio::sync::Semaphore` | N/A | Limit concurrent access | Tokio: Async-aware |
| Atomic Cell | `AtomicU32`, etc. | `AtomicCell<T>` | Thread-safe mutable locations | Crossbeam: More flexible types |
| Work-stealing | N/A | `crossbeam_deque::Worker`, `Stealer` | Task schedulers, parallel algorithms | Efficient work distribution |
| Epoch-based GC | N/A | `crossbeam_epoch` | Lock-free data structures | Safe memory reclamation |
| Scoped Threads | N/A | `crossbeam::scope` | Borrowing stack data in threads | Lightweight thread spawning |
| Concurrent Queue | N/A | `ArrayQueue`, `SegQueue` | MPMC queues | Lock-free, bounded/unbounded |
| Parker | `tokio::task::yield_now()` | `Parker` | Thread parking and unparking | Crossbeam: More low-level control |
| Wait Groups | N/A | `WaitGroup` | Synchronize multiple threads | Efficient thread coordination |
| Operation | Tokio | Crossbeam | Notes |
| ----------- | ------------------------ | ---------------------- | ----------------------------------- |
| Send | `sender.send(msg).await` | `sender.send(msg)` | Tokio is async, Crossbeam is sync |
| Receive | `receiver.recv().await` | `receiver.recv()` | Tokio is async, Crossbeam is sync |
| Clone | `sender.clone()` | `sender.clone()` | Both support cloning senders |
| Close | `drop(sender)` | `drop(sender)` | Dropping last sender closes channel |
| Try Send | `sender.try_send(msg)` | `sender.try_send(msg)` | Non-blocking send attempt |
| Try Receive | `receiver.try_recv()` | `receiver.try_recv()` | Non-blocking receive attempt |
#programming
#computing
#software #cheatsheet