Expand description
An async-compatible thread-pool aiming for “speed through simplicity”.
Forte is a parallel & async work scheduler designed to accommodate very large
workloads with many short-lived tasks. It replicates the rayon_core
api
but with native support for futures and async tasks. Its design was
prompted by the needs of the bevy game engine, but should be applicable to
any problem that involves running both synchronous and asynchronous work
concurrently.
The thread-pool provided by this crate does not employ work-stealing. Forte instead uses “Heartbeat Scheduling”, an alternative load-balancing technique that (theoretically) provides provably small overheads and good utilization. The end effect is that work is only parallelized every so often, allowing more work to be done sequentially on each thread and amortizing the synchronization overhead.
§Acknowledgments
Large portions of the code are direct ports from various versions of
rayon_core
, with minor simplifications and improvements. We also relied
upon chili
and spice
for reference while writing the heartbeat
scheduling. Support for futures is based on an approach sketched out by
members of the rayon
community to whom we are deeply indebted.
Structs§
- Scope
- A scope which can spawn a number of non-static jobs and async tasks. See
ThreadPool::scope
for more information. - Thread
Pool - The
ThreadPool
object is used to orchestrate and distribute work to a pool of threads, and is generally the main entry point to usingForte
. - Worker
- Holds the local context for a thread pool member, which allows queuing, executing, and sharing jobs on the pool.
Enums§
- Yield
- Describes the outcome of a call to
Worker::yield_now
orWorker::yield_local
.
Functions§
- block_
on - Blocks the thread waiting for a future to complete.
- join
- Executes two closures on the current thread pool and returns the results.
- scope
- Creates a scope that allows spawning non-static jobs.
- spawn
- Spawns a thread onto the current thread pool.
- spawn_
async - Spawns an async closure onto the current thread pool.
- spawn_
future - Spawns a future onto the current thread pool.