Crate messaging_thread_pool

Crate messaging_thread_pool 

Source
Expand description

§Messaging thread pool

Messaging thread pool is a collection of traits and structs for setting up a simple fixed-sized thread pool which holds a collection of a given type.

Instances of the objects are identified by an id which is unique within the thread pool.

Objects are distributed across the thread pool based on their id and ownership of the object is held there.

Objects are communicated with via a user defined set of messages which effectively form an API. These messages are sent and received over crossbeam channels.

The objects need to implement a set of simple traits and define a set of request/response messages to allow the thread pool infrastructure to handle the objects and to route messages to them.

The lifetimes of the objects are easy to reason about, as is the behaviour of the thread pools themselves.

The original motivation was to provide support for a hierarchy of dependent, long-lived objects, that each required their own thread pools to avoid complex threading dependencies.

Re-exports§

pub use request_response::RequestResponse;
pub use id_being_processed::*;
pub use pool_item::*;
pub use sender_couplet::*;
pub use thread_request_response::*;

Modules§

api_specification
global_test_scope
id_based_writer
id_being_processed
id_provider
pool_item
request_response
samples
sender_and_receiver_raw_mock
sender_couplet
thread_request_response

Macros§

api_specification
This macro generates an API enum and implements various generics and conversions for provided types.

Structs§

IdBasedBlocking
This struct is used to encapsulate the functionality of the IdBasedBlocking struct
SenderAndReceiverMock
This structure enables the mocking of a crate::ThreadPool
ThreadPool
This struct represents a pool of threads that can target a particular type of resource (a resource being a struct that implements PoolItem)

Constants§

ID_BEING_PROCESSED

Traits§

IdTargeted
This trait is implemented by requests that are targeted at a pool item with an id and by the corresponding responses coming back from said pool item. This trait is used internally by the thread pool to route requests to the appropriate thread in the thread pool.
RequestWithResponse
This trait allows for the pairing of requests and responses.
SenderAndReceiver
This trait allows a consumer to use a trait instead of the concrete implementation of thread pool. Unfortunately the send_and_receive are not a precise match for corresponding function in crate::ThreadPool itself. This is because of the limitation of the trait return types (it has to return a boxed iterator)
ThreadSafeSenderAndReceiver
This trait is useful when multiple levels are thread pools are used and each thread pool needs to be send and sync in order to be sent through the levels

Attribute Macros§

pool_item