pub trait PoolItem: Debugwhere
    Self: Sized,
    Self::Init: RequestResponseMessage<ADD_POOL_ITEM, true> + IdTargeted,
    Self::Api: Debug + Send + IdTargeted,
{ type Init; type Api; fn process_message(
        &mut self,
        request: Self::Api
    ) -> ThreadRequestResponse<Self>; fn new_pool_item(request: Self::Init) -> Result<Self, NewPoolItemError>; fn id_not_found(request: &Self::Api) -> ThreadRequestResponse<Self> { ... } fn name(&self) -> &str { ... } fn shutdown_pool(&self) -> Vec<ThreadShutdownResponse> { ... } fn add_element_request_tracing(
        id: usize
    ) -> Option<(DefaultGuard, Vec<WorkerGuard>)> { ... } fn add_pool_thread_tracing(
        id: usize
    ) -> Option<(DefaultGuard, Vec<WorkerGuard>)> { ... } }
Expand description

This is the trait that needs to be implemented by a struct in order that it can be managed by the thread pool infrastructure

Required Associated Types§

This is a struct that defines the message that will initiate a new instance of the struct within the thread pool

This is the enum that will define that messaging api that can be used to communicate with instances of the struct It will be an enum where each variant will define a request/response pair of structs

Required Methods§

This is the function that will define how the struct processes the messages that it receives. It will typically consist of a match statement that will discriminate amongst the various messages type defined in the Api

This function defines how a new struct will be created when it receives The Init message. It returns the created new instance of the struct

Provided Methods§

The function called if an item with the specified is not found The default behaviour is to panic

used for debug only; allows logging to output the name of the type

This function is a hook that is called when the pool is shutting down.

This method is called to optionally add tracing before each message is processed. The tracing is removed once the message is processed. If the tracing is being written to a file it is important that the file is not truncated

This method provides any required tracing in the pool items thread pool threads This tracing is added when the thread is spawned and remains in place until the thread dies

Implementors§

The implementation of this trait allows the Randoms struct to be used in the thread pool infrastructure