Struct Signal

Source
pub struct Signal<I, O, F>
where F: SigFn<I, O>,
{ /* private fields */ }
Expand description

Signals are the bread and butter of the crate. A signal can trigger other signals whose input is the same output as the original signal. Signals support both threaded and non-threaded children.

Implementations§

Source§

impl<I, O, F> Signal<I, O, F>
where F: 'static + SigFn<I, O> + Send + Sync, O: 'static + Send + Sync + Clone, I: 'static + Send + Sync,

Source

pub fn new_arc_mutex(f: F) -> Am<Signal<I, O, impl SigFn<I, O>>>

Create a thread-safe parent signal. Note that the return function is Arc<Mutex<Signal<>>>

Source

pub fn create_listener<Q, G>( &mut self, f: G, ) -> Am<Signal<O, Q, impl SigFn<O, Q>>>
where G: 'static + SigFn<O, Q> + Send + Sync, Q: 'static + PartialEq + Send + Sync + Clone, O: 'static,

This method is a helper for Signal::new(f) and register_listener(…)

Source

pub fn create_threaded_listener<Q, G>( &mut self, f: G, ) -> Am<Signal<O, Q, impl SigFn<O, Q>>>
where G: 'static + SigFn<O, Q> + Send + Sync, Q: 'static + PartialEq + Send + Sync + Clone, O: 'static,

This method is a helper for Signal::new(f) and register_threaded_listener(…)

Source

pub fn register_listener<E>(&mut self, strong: &Am<E>)
where E: 'static + Emitter<input = O>,

Register a child listener that will execute in the same thread as Self.

Source

pub fn register_threaded_listener<E>(&mut self, strong: &Am<E>)
where E: 'static + Emitter<input = O>,

Register a child listener that will run on its own thread.

Source

pub fn get(&self) -> &Option<O>

Get the last result of this signal… if it exists

Trait Implementations§

Source§

impl<I, O, F> Emitter for Signal<I, O, F>
where F: 'static + SigFn<I, O> + Send + Sync, O: 'static + PartialEq + Send + Sync + Clone, I: 'static + Send + Sync,

Source§

fn emit(&mut self, data: Self::input)

Run closure implemented for signal and pass on the results to children.

Source§

type input = I

Auto Trait Implementations§

§

impl<I, O, F> Freeze for Signal<I, O, F>
where F: Freeze, O: Freeze,

§

impl<I, O, F> RefUnwindSafe for Signal<I, O, F>

§

impl<I, O, F> Send for Signal<I, O, F>
where F: Send, I: Send, O: Send,

§

impl<I, O, F> Sync for Signal<I, O, F>
where F: Sync, I: Sync, O: Sync,

§

impl<I, O, F> Unpin for Signal<I, O, F>
where F: Unpin, I: Unpin, O: Unpin,

§

impl<I, O, F> UnwindSafe for Signal<I, O, F>
where F: UnwindSafe, I: UnwindSafe, O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.