pub fn open(&mut self, mut callback: impl FnMut(T) + 'static + Send + Sync) -> Result<(), SlotError> {
        if self.thread_abort_sender.is_none() {
            self.receiver_handle = None;
        }
        let rec = self.receiver.clone();
        match &self.receiver_handle {
            None => {
                let (thread_lifeline_sender, thread_lifeline_receiver) = unbounded::<()>();
                let (thread_abort_sender, thread_abort_receiver) = unbounded::<bool>();
                self.thread_lifeline_receiver = Some(thread_lifeline_receiver);
                self.thread_abort_sender = Some(thread_abort_sender);
                let update_interval = self.update_interval;
                let poll_time = self.poll_time;
                self.receiver_handle = Some(thread::spawn(move || {
                    let mut current_time = Instant::now();
                    'event_loop: loop {
                        if let Ok(x) = rec.read() {
                            if let Ok(y) = x.try_recv() {
                                (callback)(y);
                            }
                        }
                        if thread_lifeline_sender.send(()).is_err() {
                            break 'event_loop;
                        }
                        if let Ok(x) = thread_abort_receiver.try_recv() {
                            if x {
                                break 'event_loop;
                            }
                        }
                        if current_time.elapsed() > poll_time {
                            std::thread::sleep(update_interval);
                            current_time = Instant::now();
                        }
                    }
                }));
                Ok(())
            },
            Some(_) => Err(SlotError::AlreadyOpen)
        }
    }
///
///Opens this slot to receiving signals
///
/// This spawns a new 'event loop' thread for the slot to poll for signals and call the
/// 'callback' closure upon receiving them. If the Slot is already open, nothing is done and
/// SlotError::AlradyOpen is returned.
///
/// # Arguments
/// * 'callback' - the closure to call upon receiving a signal. Because this is called on a
///                separate thread, objects captured by the closer must be threadsafe (Send +
///                Sync)
///
/// # Returns
/// * success - Ok(())
/// * failure - Err(SlotError::AlreadyOpen)
///
Opens this slot to receiving signals
This spawns a new 'event loop' thread for the slot to poll for signals and call the
'callback' closure upon receiving them. If the Slot is already open, nothing is done and
SlotError::AlradyOpen is returned.

Arguments
'callback' - the closure to call upon receiving a signal. Because this is called on a
separate thread, objects captured by the closer must be threadsafe (Send +
Sync)

Returns
success - Ok(())
failure - Err(SlotError::AlreadyOpen)
Opens this slot to receiving signals This spawns a new ' event loop ' thread for the slot to poll for signals and call the ' callback ' closure upon receiving them . If the Slot is already open nothing is done and SlotError :: AlradyOpen is returned . Arguments ' callback ' - the closure to call upon receiving a signal . Because this is called on a separate thread objects captured by the closer must be threadsafe ( Send + Sync ) Returns success - Ok (( )) failure - Err ( SlotError :: AlreadyOpen )
pub fn open(&mut self, mut callback: impl FnMut(T) + 'static + Send + Sync) -> Result<(), SlotError> {
        if self.thread_abort_sender.is_none() {
            self.receiver_handle = None;
        }
        let rec = self.receiver.clone();
        match &self.receiver_handle {
            None => {
                let (thread_lifeline_sender, thread_lifeline_receiver) = unbounded::<()>();
                let (thread_abort_sender, thread_abort_receiver) = unbounded::<bool>();
                self.thread_lifeline_receiver = Some(thread_lifeline_receiver);
                self.thread_abort_sender = Some(thread_abort_sender);
                let update_interval = self.update_interval;
                let poll_time = self.poll_time;
                self.receiver_handle = Some(thread::spawn(move || {
                    let mut current_time = Instant::now();
                    'event_loop: loop {
                        if let Ok(x) = rec.read() {
                            if let Ok(y) = x.try_recv() {
                                (callback)(y);
                            }
                        }
                        if thread_lifeline_sender.send(()).is_err() {
                            break 'event_loop;
                        }
                        if let Ok(x) = thread_abort_receiver.try_recv() {
                            if x {
                                break 'event_loop;
                            }
                        }
                        if current_time.elapsed() > poll_time {
                            std::thread::sleep(update_interval);
                            current_time = Instant::now();
                        }
                    }
                }));
                Ok(())
            },
            Some(_) => Err(SlotError::AlreadyOpen)
        }
    }
pub fn open ( & mut self , mut callback : impl FnMut ( T ) + ' static + Send + Sync ) -> Result < ( ) , SlotError > { if self . thread_abort_sender . is_none ( ) { self . receiver_handle = None ; } let rec = self . receiver . clone ( ) ; match & self . receiver_handle { None => { let ( thread_lifeline_sender , thread_lifeline_receiver ) = unbounded :: < ( ) > ( ) ; let ( thread_abort_sender , thread_abort_receiver ) = unbounded :: < bool > ( ) ; self . thread_lifeline_receiver = Some ( thread_lifeline_receiver ) ; self . thread_abort_sender = Some ( thread_abort_sender ) ; let update_interval = self . update_interval ; let poll_time = self . poll_time ; self . receiver_handle = Some ( thread :: spawn ( move | | { let mut current_time = Instant :: now ( ) ; ' event_loop : loop { if let Ok ( x ) = rec . read ( ) { if let Ok ( y ) = x . try_recv ( ) { ( callback ) ( y ) ; } } if thread_lifeline_sender . send ( ( ) ) . is_err ( ) { break ' event_loop ; } if let Ok ( x ) = thread_abort_receiver . try_recv ( ) { if x { break ' event_loop ; } } if current_time . elapsed ( ) > poll_time { std :: thread :: sleep ( update_interval ) ; current_time = Instant :: now ( ) ; } } } ) ) ; Ok ( ( ) ) } , Some ( _ ) => Err ( SlotError :: AlreadyOpen ) } }
Opens this slot to receiving signals
This spawns a new 'event loop' thread for the slot to poll for signals and call the
'callback' closure upon receiving them.
Opens this slot to receiving signals This spawns a new ' event loop ' thread for the slot to poll for signals and call the ' callback ' closure upon receiving them .
&mut self
callback
impl FnMut(T) + 'static + Send + Sync
&mut self
callback
impl FnMut(T) + 'static + Send + Sync