[][src]Struct maxim::system::ActorSystemConfig

pub struct ActorSystemConfig {
    pub message_channel_size: u16,
    pub send_timeout: Duration,
    pub thread_pool_size: u16,
    pub warn_threshold: Duration,
    pub time_slice: Duration,
    pub thread_wait_time: Duration,
    pub start_on_launch: bool,
}

Configuration structure for the Maxim actor system. Note that this configuration implements serde serialize and deserialize to allow users to read the config from any serde supported means.

Fields

message_channel_size: u16

The default size for the channel that is created for each actor. This can be overridden on a per-actor basis during spawning as well. Making the default channel size bigger allows for more bandwidth in sending messages to actors but also takes more memory. Also the user should consider if their actor needs a large channel then it might need to be refactored or the threads size should be increased because messages aren't being processed fast enough. The default value for this is 32.

send_timeout: Duration

Max duration to wait between attempts to send to an actor's message channel. This is used to poll a busy channel that is at its capacity limit. The larger this value is, the longer send will wait for capacity in the channel but the user should be aware that if the system is often waiting on capacity that channel may be too small or the actor may need to be refactored to process messages faster. The default value is 1 millisecond.

thread_pool_size: u16

The size of the thread pool which governs how many worker threads there are in the system. The number of threads should be carefully considered to have sufficient parallelism but not over-schedule the CPU on the target hardware. The default value is 4 * the number of logical CPUs.

warn_threshold: Duration

The threshold at which the dispatcher thread will warn the user that the message took too long to process. If this warning is being logged then the user probably should reconsider how their message processing works and refactor big tasks into a number of smaller tasks. The default value is 1 millisecond.

time_slice: Duration

This controls how long a processor will spend working on messages for an actor before yielding to work on other actors in the system. The dispatcher will continue to pluck messages off the actor's channel and process them until this time slice is exceeded. Note that actors themselves can exceed this in processing a single message and if so, only one message will be processed before yielding. The default value is 1 millisecond.

thread_wait_time: Duration

While Reactors will constantly attempt to get more work, they may run out. At that point, they will idle for this duration, or until they get a wakeup notification. Said notifications can be missed, so it's best to not set this too high. The default value is 10 milliseconds. This implementation is backed by a Condvar.

start_on_launch: bool

Determines whether the actor system will immediately start when it is created. The default value is true.

Methods

impl ActorSystemConfig[src]

pub fn message_channel_size(self, value: u16) -> Self[src]

Return a new config with the changed message_channel_size.

pub fn send_timeout(self, value: Duration) -> Self[src]

Return a new config with the changed send_timeout.

pub fn thread_pool_size(self, value: u16) -> Self[src]

Return a new config with the changed thread_pool_size.

pub fn warn_threshold(self, value: Duration) -> Self[src]

Return a new config with the changed warn_threshold.

pub fn time_slice(self, value: Duration) -> Self[src]

Return a new config with the changed time_slice.

pub fn thread_wait_time(self, value: Duration) -> Self[src]

Return a new config with the changed thread_wait_time.

Trait Implementations

impl Clone for ActorSystemConfig[src]

impl Debug for ActorSystemConfig[src]

impl Default for ActorSystemConfig[src]

fn default() -> ActorSystemConfig[src]

Create the config with the default values.

impl<'de> Deserialize<'de> for ActorSystemConfig[src]

impl Serialize for ActorSystemConfig[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ActorMessage for T where
    T: 'static + Serialize + DeserializeOwned + Sync + Send + Any + ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,