forked from SoniEx2/rust.eventbus
Fix calling inherent instead of trait methods
This commit is contained in:
parent
bfb4b4b2d7
commit
0fc0b42f31
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "eventbus"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
authors = ["SoniEx2 <endermoneymod@gmail.com>"]
|
||||
description = "Safe, fast and concurrent event system, inspired by the MinecraftForge event bus."
|
||||
keywords = ["event", "safe", "fast", "concurrent", "bus"]
|
||||
|
@ -10,3 +10,10 @@ repository = "https://cybre.tech/SoniEx2/rust.eventbus"
|
|||
[dependencies]
|
||||
lazy_static = "1.1.0"
|
||||
anymap = "0.12.1"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.2.5"
|
||||
|
||||
[[bench]]
|
||||
name = "post_single_benchmark"
|
||||
harness = false
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#[macro_use]
|
||||
extern crate criterion;
|
||||
#[macro_use]
|
||||
extern crate eventbus;
|
||||
|
||||
use criterion::Criterion;
|
||||
use eventbus::{Event, EventBus};
|
||||
|
||||
struct MyEvent {
|
||||
}
|
||||
|
||||
impl Event for MyEvent {
|
||||
}
|
||||
|
||||
fn my_hook(_event: &mut MyEvent) {
|
||||
}
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
let bus = EventBus::new();
|
||||
register_hook!(&bus, 0, MyEvent, my_hook);
|
||||
c.bench_function("one_hook", move |b| b.iter(|| post_event!(&bus, MyEvent, &mut MyEvent {})));
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
|
@ -55,11 +55,11 @@ macro_rules! post_event {
|
|||
let handlers = $crate::get_post_targets::<$t>($b, event, id);
|
||||
for (_pri, fun) in handlers.iter() {
|
||||
fun(event);
|
||||
if <$t>::cancellable() && event.cancelled() {
|
||||
if <$t as $crate::Event>::cancellable() && <$t as $crate::Event>::cancelled(event) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
<$t>::cancellable() && event.cancelled()
|
||||
<$t as $crate::Event>::cancellable() && <$t as $crate::Event>::cancelled(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue