pub struct Events<T> { /* private fields */ }Expand description
An ordered, game-owned event queue. No hidden dispatch or subscriptions.
Producers call Self::send, readers inspect Self::read, and the game
clears or drains the queue at an explicit phase boundary. Several readers
can see the same events before clear. Preallocate for hot simulation paths.
use rayengine_core::events::Events;
struct Hit { damage: u32 }
let mut hits = Events::with_capacity(32);
hits.send(Hit { damage: 12 });
assert_eq!(hits.read().iter().map(|h| h.damage).sum::<u32>(), 12);
// Consume once, retaining capacity for the next tick.
assert_eq!(hits.drain().count(), 1);
assert!(hits.read().is_empty());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Events<T>
impl<T> RefUnwindSafe for Events<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for Events<T>
impl<T> Sync for Events<T>
impl<T> Unpin for Events<T>
impl<T> UnsafeUnpin for Events<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for Events<T>where
Vec<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more