Module casper_node::reactor[][src]

Expand description

Reactor core.

Any long running instance of the node application uses an event-dispatch pattern: Events are generated and stored on an event queue, then processed one-by-one. This process happens inside the reactor*, which also exclusively holds the state of the application besides pending events:

  1. The reactor pops an event off the event queue (called a Scheduler).
  2. The event is dispatched by the reactor. Since the reactor holds mutable state, it can grant any component that processes an event mutable, exclusive access to its state.
  3. Once the (synchronous) event processing has completed, the component returns an effect.
  4. The reactor spawns a task that executes these effects and eventually schedules another event.
  5. meanwhile go to 1.

Reactors

There is no single reactor, but rather a reactor for each application type, since it defines which components are used and how they are wired up. The reactor defines the state by being a struct of components, their initialization through the Reactor::new() and a method Reactor::dispatch_event() to dispatch events to components.

With all these set up, a reactor can be executed using a Runner, either in a step-wise manner using crank or indefinitely using run.

Modules

Reactor used to initialize a node.

Reactor used to join the network.

Reactor for participating nodes.

Structs

Event queue handle

A runner for a reactor.

Enums

Scheduling priority.

The value returned by a reactor on completion of the run() loop.

Traits

A drop-like trait for async compatible drop-and-wait.

Reactor core.

A reactor event type.

Functions

Converts multiple effects into another by wrapping.

Type Definitions

Event scheduler