| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Miso.Concurrent
Contents
Description
Overview
Miso.Concurrent provides Waiter, a lightweight synchronization
primitive built on MVar that the miso runtime
uses to coordinate its event loop with subscription threads.
Two constructors are available with different wakeup semantics:
waiter— many-to-one. Multiple threads may callnotifyconcurrently; only one pending notification is retained at a time (tryPutMVaris used, so rapid notifications coalesce). The single consumer callswaitto block until at least one notification arrives.oneshot— one-to-many. One thread callsnotifyto permanently unblock all threads currently (or subsequently) callingwait. Implemented withreadMVar, so the stored value is never consumed.
See also
- Miso.Effect —
Subsubscriptions that usenotifyto wake the event loop - Miso.Runtime — the event loop that calls
wait
Synchronization primitives
Synchronization primitive for event loop
Creates a new Waiter
Useful for multiple threads to wake-up / notify a single thread running in an infinite loop, waiting for work (e.g. to process an event queue).