Struct parallel_event_emitter::ParallelEventEmitter [] [src]

pub struct ParallelEventEmitter<K: EventKey = String> { /* fields omitted */ }

Parallel Event Emitter

Listeners added to the emitter will be invoked in a thread pool concurrently.

Methods

impl<K: EventKey> ParallelEventEmitter<K>
[src]

Creates a new ParallelEventEmitter with the default CpuPool

Creates a new ParallelEventEmitter with an already existing CpuPool instance.

This allows for custom thread preferences and lifecycle hooks.

Collect the names of all events being listened for.

Unfortunately, this method locks a mutex on an internal structure, so an iterator cannot be returned.

As an alternative to cloning all the event names and collecting them into a Vec, like in event_names, a visitor callback can be used to iterate all the event names more efficiently.

Add a simple listener callback that does not accept any arguments

The return value of this is a unique ID for that listener, which can later be used to remove it if desired.

Like add_listener, but the listener will be removed from the event emitter after a single invocation.

Add a listener that can accept a value passed via emit_value, or emit_value_sync if T is Clone

If no value or an incompatible value was passed to emit*, None is passed.

The return value of this is a unique ID for that listener, which can later be used to remove it if desired.

Like add_listener_value, but the listener will be removed from the event emitter after a single invocation.

Variation of add_listener_value that accepts Sync types, where intermediate copies on emit* are unnecessary.

This will attempt to use a reference to the original value passed to emit_value_sync. If a value of T was passed via emit_value, the callback will be invoked with the Cloned copy.

There is nothing statically forcing the use of this instead of add_listener_value, but it is here just in case your type T is Sync but might not implement Clone, or if you want to avoid cloning values all over the place.

The return value of this is a unique ID for that listener, which can later be used to remove it if desired.

Like add_listener_sync, but the listener will be removed from the event emitter after a single invocation.

Removes a listener with the given ID and associated with the given event.

If the listener was not found (either doesn't exist or the wrong event given) Ok(false) is returned.

If the listener was removed, Ok(true) is returned.

Exhaustively searches through ALL events for a listener with the given ID.

Ok(false) is returned if it was not found.

Emit an event, invoking all the listeners for that event in the thread pool concurrently.

The Future returned by emit resolves to the number of listeners invoked, and any errors should be forwarded up.

Emit an event, invoking all the listeners for that event in the thread pool concurrently.

A copy of the value will be passed to every listener.

The Future returned by emit_value resolves to the number of listeners invoked, and any errors should be forwarded up.

Variation of emit_value for Sync types, where intermediate copies are unnecessary.

All listeners receive a reference to the same value.

The Future returned by emit_value_sync resolves to the number of listeners invoked, and any errors should be forwarded up.

Trait Implementations

impl<K: EventKey> Default for ParallelEventEmitter<K>
[src]

Returns the "default value" for a type. Read more