Expand description
proxima::sync — runtime-agnostic concurrency primitives shaped like
tokio::sync. Users get the API surface they expect (use proxima_primitives::sync::Mutex;) without pulling tokio. Backing crates are
futures (channels, lock::Mutex), async-lock (RwLock, Semaphore),
event-listener (Notify), and async-broadcast (watch, broadcast).
The trait set re-exported here is concurrency-defining; runtime
coupling (spawn, timers, per-core context) stays on the
Runtime trait. See the proxima-tokio-elimination-library plan (P1.3).
Tier: notify, oneshot, shutdown, and AsyncMutex (the
async-mutex feature) compile under no_std + alloc (each backing
crate has a no_std + alloc path; see DC-SYNC). The watch primitive
uses std::sync::RwLock<T> for its value cache and is gated behind
the std feature, as are the other remaining primitives (mpsc,
mutex, once_cell, rwlock, semaphore, broadcast) — full no_std + alloc
landing for those is deferred per DC-SYNC.
blocking and task fold in the former proxima-lock and
proxima-task crates (Workstream F, RISC-dedup) — one runtime-agnostic
concurrency/task crate instead of three.
Modules§
- blocking
proxima_primitives::sync::blocking— canonical tier-resolved BLOCKING mutex.- broadcast
proxima::sync::broadcast— multi-producer multi-consumer broadcast channel, shape-compatible withtokio::sync::broadcast. Backed byasync_broadcastconfigured for overflow semantics: producers never block; if the buffer fills, the oldest message is dropped and the affected receivers seeRecvError::Lagged(skipped)on their nextrecv.- mpsc
proxima::sync::mpsc— multi-producer single-consumer channel, shape-compatible withtokio::sync::mpsc. Backed byasync-channelbecause tokio’sSender::send(&self, T)shape — async send without a&mutborrow — requires interior synchronization thatasync-channelprovides directly.futures::channel::mpsc’s capacity-per-clone semantics inflate buffers unexpectedly when used the same way, so we route throughasync-channelinstead.- oneshot
proxima::sync::oneshot— single-value channel, shape-compatible withtokio::sync::oneshot. Backed byfutures::channel::oneshot(no runtime coupling). The receiver’sawaitresolves toResult<T, Canceled>rather than tokio’sRecvError; callers that only care about success/failure (.ok(),.is_err()) port verbatim. Code that explicitly matches onRecvErrormust adapt toCanceled.- shutdown
- Cross-core graceful shutdown with per-core resource ordering.
- task
proxima_primitives::sync::task— runtime-agnostic task primitives shaped liketokio::task. Folded from the formerproxima-taskcrate (Workstream F, RISC-dedup) so other proxima leaf crates (proxima-middleware, proxima-listeners-*, prime, etc.) reach it via the same crate as the rest of proxima’s concurrency surface, without circling back through the top-level proxima crate.- watch
proxima::sync::watch— single-producer, multi-consumer latest-value channel. Shape-compatible withtokio::sync::watch: each receiver tracks whether it has observed the current value; slow receivers don’t block fast ones; back-to-back sends collapse to the last value if the consumer hasn’t calledchanged()in between.
Structs§
- Acquire
Error - Error returned by
acquire().awaitwhen the semaphore is closed. - Barrier
- Multi-party rendezvous, shape-compatible with
tokio::sync::Barrier. Direct re-export ofasync_lock::Barrier.wait()resolves onceNtasks have called it. Useful for staged pipeline startup (every worker reaches a barrier together) and integration tests. A counter to synchronize multiple tasks at the same time. - Mutex
- Async mutex matching
tokio::sync::Mutex’s API shape, backed byfutures::lock::Mutex. - Mutex
Guard - An RAII guard returned by the
lockandtry_lockmethods. When this structure is dropped (falls out of scope), the lock will be unlocked. - Mutex
Lock Future - A future which resolves when the target mutex has been successfully acquired.
- Notified
- Future returned by
Notify::notified. Can be explicitly registered without polling viaNotified::enableto close lost-wakeup races between state check and park. - Notify
- Once
Cell - A memory location that can be written to at most once.
- RwLock
- Async reader-writer lock matching
tokio::sync::RwLock’s shape. - RwLock
Read Guard - A guard that releases the read lock when dropped.
- RwLock
Write Guard - A guard that releases the write lock when dropped.
- Semaphore
- Counted async semaphore.
- Semaphore
Guard - A guard that releases the acquired permit.
- Semaphore
Guard Arc - An owned guard that releases the acquired permit.
- Semaphore
Permit - Acquired permit. Releases back into the pool on drop.
- TryLock
Error - Error returned by
Mutex::try_lockwhen the lock would block. Matchestokio::sync::TryLockError’s shape (unit-payload).
Enums§
- TryAcquire
Error - Error returned by
try_acquire().