1
0
Fork 0
roguelike-game/src/systems/dispatcher/multi_thread.rs

43 lines
977 B
Rust
Raw Normal View History

2022-02-03 10:17:02 -05:00
use ::specs::prelude::*;
use super::UnifiedDispatcher;
macro_rules! construct_dispatcher {
(
$(
(
$type:ident,
$name:expr,
$deps:expr
)
),*
) => {
fn new_dispatch() -> Box<dyn UnifiedDispatcher + 'static> {
use ::specs::DispatcherBuilder;
let dispatcher = DispatcherBuilder::new()
$(
.with($type{}, $name, $deps)
)*
.build();
let dispatch = MultiThreadedDispatcher {
dispatcher
2022-02-03 10:17:02 -05:00
};
return Box::new(dispatch);
}
};
}
pub struct MultiThreadedDispatcher {
pub dispatcher: ::specs::Dispatcher<'static, 'static>,
}
impl<'a> UnifiedDispatcher for MultiThreadedDispatcher {
fn run_now(&mut self, ecs: &mut World) {
self.dispatcher.dispatch(ecs);
crate::effects::run_effects_queue(ecs);
2022-02-03 10:17:02 -05:00
}
}