1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! Inter-process communication subsystem.
//!
//! Linux equivalent: `ipc/`
//!
//! This module provides the event system for kernel-driver-module communication.
//! It includes:
//!
//! - **Event Bus**: Type-erased pub/sub event dispatch
//! - **`EventScope`**: GC-like synchronization for event lifecycle tracking
//! - **Channels**: MPSC and oneshot channels for direct communication
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ EventBus │
//! │ │
//! │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
//! │ │ Subscription │ │ Subscription │ │ Subscription │ │
//! │ │ Handler A │ │ Handler B │ │ Handler C │ │
//! │ └──────────────┘ └──────────────┘ └──────────────┘ │
//! │ │ │ │ │
//! │ └───────────────────┼───────────────────┘ │
//! │ │ │
//! │ ┌────────┴────────┐ │
//! │ │ DynEvent │ │
//! │ │ (type-erased) │ │
//! │ └────────┬────────┘ │
//! │ │ │
//! │ ┌────────┴────────┐ │
//! │ │ EventScope │ │
//! │ │ (lifecycle sync)│ │
//! │ └─────────────────┘ │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Design Philosophy
//!
//! Following Linux kernel "mechanism, not policy":
//! - Provides communication primitives
//! - No opinion on message routing strategy
//! - Runtime integration is left to higher layers
//!
//! # Performance Characteristics
//!
//! - **Lock-free dispatch**: Handler lookup uses `ArcSwap` for O(1) reads
//! - **RCU subscriptions**: Copy-on-write prevents blocking dispatch
//! - **Fire-and-forget**: No error propagation from handlers
//!
//! # Example
//!
//! ```
//! use reovim_kernel::api::v1::*;
//!
//! // Define an event
//! #[derive(Debug)]
//! struct BufferChanged { buffer_id: u64 }
//! impl Event for BufferChanged {}
//!
//! // Create event bus
//! let bus = EventBus::new();
//!
//! // Subscribe handler
//! let _sub = bus.subscribe::<BufferChanged, _>(100, |event| {
//! println!("Buffer {} changed", event.buffer_id);
//! EventResult::Handled
//! });
//!
//! // Emit event
//! bus.emit(BufferChanged { buffer_id: 1 });
//!
//! // With scope tracking
//! let scope = EventScope::new();
//! scope.increment();
//! bus.emit_scoped(BufferChanged { buffer_id: 2 }, &scope);
//! assert!(scope.is_complete());
//! ```
// Re-export channel types
pub use ;
// Re-export context types
pub use ;
// Re-export event types
pub use ;
// Re-export event bus
pub use ;
// Re-export scope types
pub use ;
// Re-export subscription types
pub use ;