Skip to main content

AgentRegistry

Struct AgentRegistry 

Source
pub struct AgentRegistry { /* private fields */ }
Expand description

Registry that manages all registered agents with automatic priority ordering.

Agents are automatically sorted by priority (highest first) and can be iterated in execution order.

Implementations§

Source§

impl AgentRegistry

Source

pub fn new() -> Self

Creates a new empty registry.

Source

pub fn register(&mut self, agent: Arc<Mutex<dyn Agent>>, priority: f32)

Registers an agent with the given priority.

Higher priority values mean the agent is updated first. The agent is active in all engine modes.

Source

pub fn register_for_mode( &mut self, agent: Arc<Mutex<dyn Agent>>, priority: f32, modes: Vec<EngineMode>, )

Registers an agent with the given priority, active only in the specified modes.

Higher priority values mean the agent is updated first. If modes is empty, the agent is active in all modes.

Source

pub fn len(&self) -> usize

Returns the number of registered agents.

Source

pub fn is_empty(&self) -> bool

Returns true if no agents are registered.

Source

pub fn iter(&self) -> impl Iterator<Item = &Arc<Mutex<dyn Agent>>>

Returns an iterator over all agents in priority order (highest first).

Source

pub fn all_ids(&self) -> Vec<AgentId>

Returns the [AgentId]s of every registered agent in priority order.

Used by the scheduler to seed a fresh AgentCompletionMap per frame.

Source

pub fn initialize_all(&self, context: &mut EngineContext<'_>)

Initializes all agents once after registration.

Calls on_initialize() on each agent in priority order, giving them access to the engine services for caching and lane setup.

Source

pub fn execute_all(&self, context: &mut EngineContext<'_>)

Executes all agents in priority order.

Called each frame. Each agent selects the appropriate lanes and dispatches their execution.

Source

pub fn get_by_id(&self, id: AgentId) -> Option<Arc<Mutex<dyn Agent>>>

Returns the agent with the given ID, if registered.

Source

pub fn collect_for_phase( &self, phase: ExecutionPhase, mode: &EngineMode, ) -> Vec<PhaseAgentEntry>

Collects agents that are allowed to run in the given phase and mode. Returns a list of (agent, importance, priority, dependencies).

Source

pub fn execute_agent( &self, id: AgentId, context: &mut EngineContext<'_>, ) -> bool

Executes a specific agent by ID.

Trait Implementations§

Source§

impl Default for AgentRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AppLifecycle for T
where T: ?Sized,

§

fn on_start(&mut self, ctx: &mut dyn AppContext)

Called once after the backend is up but before the first update. Apps install their theme / fonts here.
§

fn on_exit(&mut self)

Called once when the window is closing. Persist state here.
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the inner value as &dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.