feat: add internal ZCLAW kernel crates to git tracking

This commit is contained in:
iven
2026-03-22 09:26:36 +08:00
parent d72c0f7161
commit 58cd24f85b
36 changed files with 10298 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
//! Event bus for kernel events
use tokio::sync::broadcast;
use zclaw_types::Event;
/// Event bus for publishing and subscribing to events
pub struct EventBus {
sender: broadcast::Sender<Event>,
}
impl EventBus {
/// Create a new event bus
pub fn new() -> Self {
let (sender, _) = broadcast::channel(1000);
Self { sender }
}
/// Publish an event
pub fn publish(&self, event: Event) {
// Ignore send errors (no subscribers)
let _ = self.sender.send(event);
}
/// Subscribe to events
pub fn subscribe(&self) -> broadcast::Receiver<Event> {
self.sender.subscribe()
}
}
impl Default for EventBus {
fn default() -> Self {
Self::new()
}
}