Crate hey_listen[−][src]
Hey_listen
is a collection of event-dispatchers aiming to suit all needs!
Covering synchronous, parallel, and sync-prioritised dispatching to
Closures, Enums, Structs, and every other type supporting trait
-implementation.
View the examples
on how to use each dispatcher.
Usage
Add this to your Cargo.toml
:
[dependencies]
hey_listen = "0.5"
Example
Here is a quick example on how to use the sync event-dispatcher:
use hey_listen::sync::{ ParallelDispatcher, ParallelListener, ParallelDispatchResult, }; #[derive(Clone, Eq, Hash, PartialEq)] enum Event { EventType, } struct ListenerStruct; impl ParallelListener<Event> for ListenerStruct { fn on_event(&self, event: &Event) -> Option<ParallelDispatchResult> { println!("I'm listening! :)"); None } } let listener = ListenerStruct; let mut dispatcher: ParallelDispatcher<Event> = ParallelDispatcher::new(8).expect("Could not construct threadpool"); dispatcher.add_listener(Event::EventType, listener);
Modules
rc | The blocking dispatcher module. |
sync | The parallel/async dispatcher module. |
Enums
Error |
|
Type Definitions
Mutex | A mutual exclusion primitive useful for protecting shared data |
RwLock | A reader-writer lock |