Expand description
reactor: the bridge that makes a SubEtha ring a first-class async
source ACROSS processes, not just across threads.
Intra-process async is direct: the producer holds the consumer’s
Waker and fires it on push (see crate::waker_ring). Across
processes the producer is in another address space and cannot touch
a local Waker, so a parked future needs something in THIS process
to notice the cross-process publish and fire its Waker. That is
the reactor: one background thread per process that blocks on the
MMF CrossProcessWaker, and when another process publishes, fires
the local Waker of the
future parked on the ring. It is the epoll/IOCP reactor pattern with
the readiness source being a shared-memory ring head instead of a
socket.
§One surface, two locales
ReactiveReceiver::recv returns the same future whether the
producer is a thread or a process:
anon_pairbuilds an intra-process channel; the sender fires the receiver’sWakerdirectly, no reactor thread.receiver_cross/sender_crossbuild the cross-process halves over a shared MMF ring + named waker; a reactor thread in the consumer bridges the publish to the localWaker.
Unlike crate::async_ring, which spawns one OS thread per
in-flight future, the reactor uses ONE thread per process regardless
of how many futures park on the ring.
§block_on
block_on is a minimal thread-parking driver: it sleeps the
calling thread between polls and is unparked by the future’s Waker.
Paired with the reactor, a consumer process genuinely sleeps (both
the driver thread and the reactor thread park in the kernel) until
another process publishes - no busy-spin.
Structs§
- Reactive
Receiver - Consumer half.
recv()is an.await-able future that resolves when an item arrives, suspending the task until then - off-thread across threads OR across processes, behind the same call. - Reactive
Recv - Future returned by
ReactiveReceiver::recv. - Reactive
Sender - Producer half.
try_sendpublishes the payload and signals the consumer - a directWakerfire intra-process, an MMF wake cross-process.
Functions§
- anon_
pair - Intra-process reactive channel: the sender fires the receiver’s
Wakerdirectly on push. No reactor thread.capacitymust be a power of two. - block_
on - Drive a future to completion on the current thread, parking the
thread between polls. The future’s
Wakerunparks it; a reactor (or a local sender) fires thatWakeron readiness. - receiver_
cross - Cross-process consumer half. Spawns a reactor thread that blocks on
the shared waker and fires the local
Wakerof the future parked on the ring whenever the producer process publishes. - sender_
cross - Cross-process producer half over a shared MMF ring + named waker. The two processes share the same ring file and the same waker file.