Event Manager
vivarium constructs and manages the flow of time
through the emission of regularly scheduled events. The tools in this module
manage the relationships between event emitters and listeners.
The EventManager maintains a mapping between event types and channels.
Each event type (and event types must be unique so event type is equivalent to
event name, e.g., time_step_prepare) corresponds to an
EventChannel, which tracks listeners to that event in prioritized
levels and passes on the event to those listeners when emitted.
For more information, see the associated event concept note.
- class vivarium.framework.event.manager.Event(name, index, user_data, time, step_size)[source]
An Event object represents the context of an event.
Events themselves are just a bundle of data. They must be emitted along an
EventChannelin order for other simulation components to respond to them.- Parameters:
- name: str
The name of the event. Typically a lifecycle state.
- index: pd.Index[int]
An index into the population table containing all simulants affected by this event.
- user_data: dict[str, Any]
Any additional data provided by the user about the event.
- time: ClockTime
The simulation time at which this event will resolve. The current simulation size plus the current time step size.
- step_size: ClockStepSize
The current step size at the time of the event.
- split(new_index)[source]
Creates a copy of this event with a new index.
This function should be used to emit an event in a new
EventChannelin response to an event emitted from a different channel.
- class vivarium.framework.event.manager.EventChannel(manager, event_name)[source]
A named subscription channel that passes events to event listeners.
- Parameters:
manager (EventManager)
event_name (str)
- class vivarium.framework.event.manager.EventManager[source]
The configuration for the event system.
Notes
Client code should never need to interact with this class except through the decorators in this module and the emitter function exposed on the builder during the setup phase.
- register_listener(event_name, listener, priority=5)[source]
Registers a new listener to the named event.