MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / run_all

Method run_all

native/shared/src/frame_callbacks.rs:58–82  ·  view source on GitHub ↗

Run all active callbacks in priority order.

(&mut self, delta_time: f64)

Source from the content-addressed store, hash-verified

56
57 /// Run all active callbacks in priority order.
58 pub fn run_all(&mut self, delta_time: f64) {
59 if !self.sorted {
60 // Sort by priority (stable sort preserves insertion order for equal priorities)
61 let mut indices: Vec<usize> = (0..self.callbacks.len()).collect();
62 indices.sort_by_key(|&i| self.callbacks[i].priority);
63
64 let old_callbacks: Vec<_> = self.callbacks.drain(..).collect();
65 let old_ids: Vec<_> = self.ids.drain(..).collect();
66 for &i in &indices {
67 self.callbacks.push(FrameCallback {
68 priority: old_callbacks[i].priority,
69 callback: old_callbacks[i].callback,
70 active: old_callbacks[i].active,
71 });
72 self.ids.push(old_ids[i]);
73 }
74 self.sorted = true;
75 }
76
77 for cb in &self.callbacks {
78 if cb.active {
79 (cb.callback)(delta_time);
80 }
81 }
82 }
83
84 /// Get number of registered callbacks.
85 pub fn count(&self) -> usize {

Callers 1

begin_frameMethod · 0.80

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected