Crate zero_pool

Source
Expand description

§Zero-Pool: Ultra-High Performance Thread Pool

A thread pool implementation designed for maximum performance through:

  • Zero-overhead task submission via raw pointers
  • Result-via-parameters pattern (no result transport)
  • Single global queue with optimal load balancing
  • Function pointer dispatch (no trait objects)
  • Lock-free queue operations with event-based worker coordination

§Safety

This library achieves high performance through raw pointer usage. Users must ensure:

  • Parameter structs remain valid until TaskFuture::wait() completes
  • Result pointers remain valid until task execution finishes
  • Task functions are thread-safe and data-race free
  • No undefined behavior in unsafe task code

§Example

use zero_pool::{ZeroPool, zp_task_params, zp_define_task_fn, zp_write};

zp_task_params! {
    MyTask { value: u64, result: *mut u64 }
}

zp_define_task_fn!(my_task, MyTask, |params| {
    zp_write!(params.result, params.value * 2);
});

let pool = ZeroPool::new();
let mut result = 0u64;
let task = MyTask::new(42, &mut result);
pool.submit_task(my_task, &task).wait();
assert_eq!(result, 84);

Macros§

zp_define_task_fn
Define a task function with automatic parameter dereferencing
zp_submit_batch_mixed
Submit a batch of mixed task types with type safety
zp_task_params
Create a task parameter struct with automatic constructor
zp_write
Write a result to a raw pointer (eliminates explicit unsafe blocks)
zp_write_indexed
Write a value to a specific index in a collection via raw pointer

Structs§

TaskFuture
A future that tracks completion of submitted tasks
ZeroPool

Functions§

uniform_tasks_to_pointers
Convert a slice of uniform task parameters to work items

Type Aliases§

TaskFnPointer
Function pointer type for task execution
TaskItem
A work item containing a task function and its parameters
TaskParamPointer
Raw pointer to task parameter struct