pub struct Pipeline<T: Send + 'static> { /* private fields */ }Expand description
One class’s standing fan: N workers, built once, parked until there is work.
Implementations§
Source§impl<T: Send + 'static> Pipeline<T>
impl<T: Send + 'static> Pipeline<T>
Sourcepub fn start<F>(
class: OpClass,
workers: usize,
depth: usize,
run: F,
) -> Pipeline<T>
pub fn start<F>( class: OpClass, workers: usize, depth: usize, run: F, ) -> Pipeline<T>
Build the fan and START it. Threads are spawned HERE, at boot — never on the request path. That is the entire point of the type.
Sourcepub fn start_with_arena<A, M, F>(
class: OpClass,
workers: usize,
depth: usize,
make: M,
run: F,
) -> Pipeline<T>
pub fn start_with_arena<A, M, F>( class: OpClass, workers: usize, depth: usize, make: M, run: F, ) -> Pipeline<T>
The same fan, but each worker owns an ARENA built once at boot.
This is the half of “zero initialisation” the plain start
does not give you. A standing fan removes the thread spawn; it does not
remove the buffer. If the work still does Vec::with_capacity per
operation, the kernel still zeroes fresh pages for it — which is
kernel_init_pages, 4.7% of the top profile on a linux.git clone,
the single largest kernel cost measured there.
make runs once per worker, at boot. run receives &mut A, so the
buffer that was grown for the first operation is still there, at capacity,
for the ten-thousandth. The caller is responsible for clear()-ing
rather than reallocating — clear keeps capacity, which is the whole
point, and is why this takes &mut A instead of handing back an owned
buffer per call.
Sourcepub fn submit(&self, item: T) -> Result<usize, SubmitError>
pub fn submit(&self, item: T) -> Result<usize, SubmitError>
Hand an operation to the standing fan. Allocates nothing but the queue slot; spawns nothing.