EventManager

Struct EventManager 

Source
pub struct EventManager {
    groups: Mutex<HashMap<GroupId, Vec<u32>>>,
    sessions: Mutex<HashMap<SessionId, Vec<u32>>>,
    named_groups: Mutex<HashMap<String, Vec<u32>>>,
    configs: Mutex<HashMap<u32, DeliveryConfig>>,
    task_filters: Mutex<HashMap<u32, Vec<(usize, EventFilter)>>>,
    next_event_id: Mutex<u64>,
    channels: Mutex<HashMap<String, Arc<EventChannelObject>>>,
}
Expand description

Event Manager - Main implementation of the event system

Fields§

§groups: Mutex<HashMap<GroupId, Vec<u32>>>

Task group memberships

§sessions: Mutex<HashMap<SessionId, Vec<u32>>>

Session memberships

§named_groups: Mutex<HashMap<String, Vec<u32>>>

Named/custom group memberships

§configs: Mutex<HashMap<u32, DeliveryConfig>>

Delivery configurations per task

§task_filters: Mutex<HashMap<u32, Vec<(usize, EventFilter)>>>

Task-specific event filters (handler_id, filter)

§next_event_id: Mutex<u64>

Next event ID

§channels: Mutex<HashMap<String, Arc<EventChannelObject>>>

Channel registry - EventManager only manages channels, channels manage their own subscriptions

Implementations§

Source§

impl EventManager

Source

pub fn new() -> Self

Create a new EventManager

Source

pub fn get_manager() -> &'static EventManager

Get the global EventManager instance

Source

fn get_current_task_id(&self) -> Option<u32>

Helper: get the currently running task id, if available

Source

pub fn create_channel(&self, name: String) -> KernelObject

Create or get an event channel as a KernelObject handle

This method creates an EventChannel that can be inserted into a HandleTable, providing consistent resource management with other kernel objects.

Source

pub fn create_subscription( &self, channel_name: String, task_id: u32, ) -> Result<KernelObject, EventError>

Create a subscription to a channel as a KernelObject handle

This method creates an EventSubscription that can be inserted into a HandleTable, allowing tasks to receive events through the standard handle interface.

Source

pub fn send_event(&self, event: Event) -> Result<(), EventError>

Send an event

Source

pub fn register_filter( &self, task_id: u32, filter: EventFilter, ) -> Result<(), EventError>

Register an event filter for a task (without handler id)

Source

pub fn register_filter_with_id( &self, task_id: u32, handler_id: usize, filter: EventFilter, ) -> Result<(), EventError>

Register an event filter for a task with explicit handler id

Source

pub fn unregister_filter_by_id( &self, task_id: u32, handler_id: usize, ) -> Result<(), EventError>

Unregister a filter by handler id

Source

pub fn get_filters_for_task(&self, task_id: u32) -> Vec<(usize, EventFilter)>

Get a snapshot of filters for a task

Source

pub fn clear_filters(&self, task_id: u32) -> Result<(), EventError>

Remove all filters for a task

Source

pub fn subscribe_channel(&self, channel: &str) -> Result<(), EventError>

Subscribe to a channel

Source

pub fn unsubscribe_channel(&self, channel: &str) -> Result<(), EventError>

Unsubscribe from a channel

Source

pub fn join_group(&self, group_id: GroupId) -> Result<(), EventError>

Join a task group

Source

pub fn leave_group(&self, group_id: GroupId) -> Result<(), EventError>

Leave a task group

Source

pub fn join_session(&self, session_id: SessionId) -> Result<(), EventError>

Join a session group

Source

pub fn leave_session(&self, session_id: SessionId) -> Result<(), EventError>

Leave a session group

Source

pub fn join_named_group(&self, name: String) -> Result<(), EventError>

Join a named/custom group

Source

pub fn leave_named_group(&self, name: &str) -> Result<(), EventError>

Leave a named/custom group

Source

pub fn configure_delivery( &self, config: DeliveryConfig, ) -> Result<(), EventError>

Configure delivery settings

Source

fn get_task_config_or_default(&self, task_id: u32) -> DeliveryConfig

Get a task’s delivery configuration or the default if none is set

Source

fn handle_delivery_failure( &self, sender: Option<u32>, err: &EventError, event: &Event, )

Handle delivery failures according to the sender’s configured policy

Source

fn deliver_direct( &self, event: Event, target: TaskId, _priority: EventPriority, _reliable: bool, ) -> Result<(), EventError>

Deliver direct event to specific task

Source

fn deliver_to_channel( &self, event: Event, channel_id: &str, create_if_missing: bool, _priority: EventPriority, ) -> Result<(), EventError>

Deliver to channel subscribers

Source

fn deliver_to_group( &self, event: Event, group_target: &GroupTarget, _priority: EventPriority, _reliable: bool, ) -> Result<(), EventError>

Deliver to group members

Source

fn deliver_broadcast( &self, event: Event, _priority: EventPriority, _reliable: bool, ) -> Result<(), EventError>

Deliver broadcast event to all tasks

Source

pub fn deliver_to_task( &self, task_id: u32, event: Event, ) -> Result<(), EventError>

Deliver event to a specific task

Source

pub fn dequeue_event_for_task(&self, task_id: u32) -> Option<Event>

👎Deprecated: Use Task.process_pending_events() instead

Dequeue the next highest priority event for a task This method is deprecated - tasks now process events directly via process_pending_events()

Source

pub fn get_pending_event_count(&self, task_id: u32) -> usize

Get the number of pending events for a task

Source

pub fn has_pending_events(&self, task_id: u32) -> bool

Check if a task has any pending events

Source

pub fn get_channel(&self, name: &str) -> Option<Arc<EventChannelObject>>

Get a channel by name, if it exists.

Source

pub fn remove_subscription_from_channel( &self, channel_name: &str, subscription_id: &str, ) -> Result<(), EventError>

Remove a subscription from a channel by name and subscription id.

Auto Trait Implementations§

§

impl !Freeze for EventManager

§

impl !RefUnwindSafe for EventManager

§

impl Send for EventManager

§

impl Sync for EventManager

§

impl Unpin for EventManager

§

impl !UnwindSafe for EventManager

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.