Struct messaging_thread_pool::samples::Randoms
source · pub struct Randoms {
pub id: usize,
pub numbers: Vec<u64>,
}Expand description
This represents a simple collection of random numbers which is hosted inside the thread pool
It is tied to a particular thread by the modulus of its id.
The interface that it supports is governed by its implementation of the PoolItem trait. This in turn needs to be supported by the use of two enums of supported requests and responses
It supports the following operations Init creates a new Random with an stack based store of random numbers Mean calculates the mean of the contained numbers Sum calculates the sum of the contained numbers
Fields§
§id: usize§numbers: Vec<u64>Implementations§
Trait Implementations§
source§impl PartialEq<Randoms> for Randoms
impl PartialEq<Randoms> for Randoms
source§impl PoolItem for Randoms
impl PoolItem for Randoms
The implementation of this trait allows the Randoms struct to be used in the thread pool infrastructure
§type Init = RandomsAddRequest
type Init = RandomsAddRequest
§type Api = RandomsApi
type Api = RandomsApi
source§fn process_message(&mut self, request: Self::Api) -> ThreadRequestResponse<Self>
fn process_message(&mut self, request: Self::Api) -> ThreadRequestResponse<Self>
source§fn add_pool_item_tracing(&self) -> Option<Vec<Box<dyn GuardDrop>>>
fn add_pool_item_tracing(&self) -> Option<Vec<Box<dyn GuardDrop>>>
source§fn new_pool_item(request: Self::Init) -> Result<Self, NewPoolItemError>
fn new_pool_item(request: Self::Init) -> Result<Self, NewPoolItemError>
source§fn shutdown_pool(&self) -> Vec<ThreadShutdownResponse>
fn shutdown_pool(&self) -> Vec<ThreadShutdownResponse>
source§fn id_not_found(request: &Self::Api) -> ThreadRequestResponse<Self>
fn id_not_found(request: &Self::Api) -> ThreadRequestResponse<Self>
source§fn add_pool_thread_tracing(
id: usize
) -> Option<(DefaultGuard, Vec<WorkerGuard>)>
fn add_pool_thread_tracing( id: usize ) -> Option<(DefaultGuard, Vec<WorkerGuard>)>
source§impl RequestWithResponse<Randoms> for MeanRequest
impl RequestWithResponse<Randoms> for MeanRequest
ties together the request with a response
type Response = MeanResponse
source§impl RequestWithResponse<Randoms> for PanicRequest
impl RequestWithResponse<Randoms> for PanicRequest
ties together the request with a response
type Response = PanicResponse
source§impl RequestWithResponse<Randoms> for RandomsAddRequest
impl RequestWithResponse<Randoms> for RandomsAddRequest
type Response = AddResponse
source§impl RequestWithResponse<Randoms> for SumRequest
impl RequestWithResponse<Randoms> for SumRequest
ties together the request with a response