1 unstable release
0.1.0 | May 9, 2022 |
---|
#48 in #worker-thread
Used in 2 crates
6KB
109 lines
Executor
This is a simple executor. There is a single Arc<Executor>
type that can be shared between many worker threads.
Each worker will continuously run executor.poll_once()
which will
- Pop a task from the shared task queue
- Parking the thread if no tasks are available
- Poll that task
The task will be polled with a context that will reference that task (using a Mutex<Option<Task>>
),
and a copy of the executor.
Calling wake on this context will then call executor.wake(task)
. If there are threads sleeping, one will be woken up.
Dependencies
~1MB
~18K SLoC