Soft question: micro components within a process

This all happens within a single process.

Is there a style of programming where we try to design a Rust process like the internet. I.e. we define

pub enum A_Msg {};
pub enum B_Msg {};
pub enum C_Msg {};
pub enum D_Msg {};
pub enum E_Msg {};

pub enum   All_msg {

then we have a global queue


and we register components for handling A_Msg, B_Msg, C_Msg, D_Msg, E_Msg, and the global handler dispatches msgs to components.

Is this a common pattern in Rust ? If so, what is the name and where can I read up more on this.

Broadly (and not specifically to Rust), you could call that an event loop; the queue is an event queue.

If instead each component has its own queue, and the component's state is solely owned by the loop that processes the messages, then the components are actors. This allows more parallelism since each actor can work independently, but in that case there is no longer a definite ordering of all messages in the entire system.


LOL. Good point. It is basically an EventLoop where the handler is a match statement dispatching to one of 5 handlers.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.