Struct kay::ActorSystem[][src]

pub struct ActorSystem {
    pub panic_happened: bool,
    pub shutting_down: bool,
    // some fields omitted
}

The main thing inside of which all the magic happens.

An ActorSystem contains the states of all registered actor instances, message inboxes (queues) for each registered Actor type, and message dispatchers for each registered (Actor, Message) pair.

It can be controlled from the outside to do message passing and handling in turns.

Fields

Flag that the system is in a panicked state

Flag that the system is shutting down

Methods

impl ActorSystem
[src]

Create a new ActorSystem (usually only one per application is needed). Expects to get a panic callback as a parameter that is called when an actor panics during message handling and can thus be used to for example display the panic error message.

Note that after an actor panicking, the whole ActorSystem switches to a panicked state and only passes messages anymore which have been marked as critically receiveable using add_handler.

Register a new Actor type with the system

Register a handler for an Actor type and Message type.

Register a handler that constructs an instance of an Actor type, given an RawID

Send a message to the actor(s) with a given RawID. This is only used to send messages into the system from outside. Inside actor message handlers you always have access to a World that allows you to send messages.

Get the base RawID of an Actor type

Processes all sent messages, and messages which are in turn sent during the handling of messages, up to a recursion depth of 1000.

This is typically called in the main loop of an application.

By sending different "top-level commands" into the system and calling process_all_messages inbetween, different aspects of an application (for example, UI, simulation, rendering) can be run isolated from each other, in a fixed order of "turns" during each main-loop iteration.

Get a world context directly from the system, typically to send messages from outside

Connect to all peers in the network

Send queued outbound messages and take incoming queued messages and forward them to their local target recipient(s)

Finish the current networking turn and wait for peers which lag behind based on their turn number. This is the main backpressure mechanism.

The machine index of this machine within the network of peers

The current network turn this machine is in. Used to keep track if this machine lags behind or runs fast compared to its peers

Return a debug message containing the current local view of network turn progress of all peers in the network

Get current instance counts for all actory types

Get number of processed messages per message type since last reset

Reset count of processed messages

Get current inbox queue lengths per actor type

Auto Trait Implementations

impl !Send for ActorSystem

impl !Sync for ActorSystem