Zero-Pool: Consistent High-Performance Thread Pool
A FIFO MPMC thread pool with a single global queue and cooperative memory reclamation.
Key Features:
- Zero locks - lock-free
- Zero queue limit - unbounded
- Zero channels - no std/crossbeam channel overhead
- Zero virtual dispatch - function pointer dispatch avoids vtable lookups
- Zero core spinning - all event-based
- Zero result transport cost - tasks write directly to caller-provided memory
- Zero per-worker queues - single global queue structure = perfect workload balancing
- Zero external dependencies - standard library only and stable Rust
- Zero heap tracking overhead - scoped tasks synchronize via stack-allocated counters (no
Arcper task)
Using a result-via-parameters pattern means workers place results into caller-provided memory, removing thread transport overhead. The single global queue structure ensures optimal load balancing without the complexity of work-stealing or load redistribution algorithms.
Notes
pool.run_detachedallows fire-and-forget background tasks without waiting.- Zero-Pool supports both explicitly creating new thread pools (
ZeroPool::new,ZeroPool::with_workers) and using the global instance (zero_pool::global_pool).
Example Usage
Running Tasks
use ZeroPool;
let pool = new;
// Single task
let mut result = 0;
pool.run;
println!;
// Batch
let mut results = vec!;
let tasks: = results.iter_mut.enumerate.map.collect;
pool.run;
println!;
Scoped Concurrent Tasks
Submit tasks of different types concurrently within a scope. All submitted tasks complete before the scope returns:
use ZeroPool;
let pool = new;
let mut compute_result = 0;
let mut multiply_result = 0;
let compute_params = ;
let multiply_params = ;
pool.scope;
println!;
Multi-Phase Coordination
Call s.wait() mid-scope to synchronize between computation phases:
let phase1_params = ;
let phase2_params = ;
pool.scope;
Using the Global Pool
use global_pool;
let mut result = 0;
global_pool.run;
println!;