forked from SoniEx2/rust.eventbus
collate cancelled
This commit is contained in:
parent
3c3e8754ad
commit
fedb32d242
|
@ -72,7 +72,6 @@ macro_rules! post_event {
|
||||||
fun(event);
|
fun(event);
|
||||||
}
|
}
|
||||||
},)+); // big tuple of (Handlers<type>, Handlers<type>, Handlers<type>, Handlers<type>, ...)
|
},)+); // big tuple of (Handlers<type>, Handlers<type>, Handlers<type>, Handlers<type>, ...)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +96,7 @@ macro_rules! post_event_cancellable {
|
||||||
}
|
}
|
||||||
|
|
||||||
test(event);
|
test(event);
|
||||||
let cancelled = ($({
|
let cancelled = [$({
|
||||||
// event type setup
|
// event type setup
|
||||||
static EVENT_ID: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
|
static EVENT_ID: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
|
||||||
static EVENT_ID_INIT: ::std::sync::Once = ::std::sync::ONCE_INIT;
|
static EVENT_ID_INIT: ::std::sync::Once = ::std::sync::ONCE_INIT;
|
||||||
|
@ -110,15 +109,16 @@ macro_rules! post_event_cancellable {
|
||||||
let handlers = $crate::get_post_targets::<$t>(bus, event, id);
|
let handlers = $crate::get_post_targets::<$t>(bus, event, id);
|
||||||
|
|
||||||
for (_pri, fun) in handlers.iter() {
|
for (_pri, fun) in handlers.iter() {
|
||||||
fun(event as &mut $t);
|
|
||||||
if Cancellable::cancelled(event) {
|
if Cancellable::cancelled(event) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
fun(event as &mut $t);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.cancelled()
|
event.cancelled()
|
||||||
},)+); // big tuple of (Handlers<type>, Handlers<type>, Handlers<type>, Handlers<type>, ...)
|
},)+]; // big tuple of (Handlers<type>, Handlers<type>, Handlers<type>, Handlers<type>, ...)
|
||||||
|
|
||||||
|
cancelled.iter().fold(false, |n, i| n || *i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue