Macro score::process_events
[−]
[src]
macro_rules! process_events { ($data:expr, $event:ident, $state:ident, $effector:ident, $($name:pat => $code:expr),+) => { ... }; }
Typically Component
threads will use this to cut down on the boiler plate involved in
processing dispatched Event
s. Note that this will panic if it tries to process an
event that doesn't have an associated code block.
Examples
use score::*; use std::thread; fn my_thread(data: ThreadData) { thread::spawn(move || { process_events!(data, event, state, effector, "init 0" => { // Use the effector to change the simulation state. let event = Event::new("timer"); effector.schedule_after_secs(event, data.id, 1.0); }, "timer" => { // Typically you'd re-schedule the timer here, log_info!(effector, "timer fired!"); } ); }); }