Expand description
A simple process semaphore.
(Note: The word process should be read as a sequence of operations, rather than an operating system process).
The ProcSem
is intended to allow mutual exclusion of a chain of
operations that may span over several threads/tasks.
This is much like a Mutex
, but it differs in that it holds no generic
parameter and the ProcCtx
(the equivalent of Mutex
’s MutexGuard
) is
Send
, because it is explicitly meant to be passed around between
threads/tasks. It supports blocking, nonblocking and async lock
acquisition.
§Progress reporting
When a ProcSem
is created, it can optionally be handed an object that
implements StateReporter
. If a ProcSem
has a StateReporter
associated with it, then an acquired ProcCtx
can use
ProcCtx::action()
, ProcCtx::progress()
to pass progress information
to the StateReporter
implementor.
Once a ProcCtx
is about to terminate, ProcCtx::end()
can be used to
signal a final message that can be retrieved by the ProcSem
object.
Structs§
- Acquire
Future - Future used to wait to acquire a
ProcCtx
in an async environment. - ProcCtx
- Object that denotes ownership of a
ProcSem
semaphore. - ProcSem
- Representation of a process that may be active or inactive.
Traits§
- State
Reporter - Interface used to implement objects that are reponsible for sending process reports.