Struct wombo::Wombo
[−]
[src]
pub struct Wombo<T: Send + 'static> { /* fields omitted */ }
A module for starting event loop threads with notifications when they exit, and with hooks for canceling any running futures.
Any cloned instances will refer to the same child thread and event loop.
Methods
impl<T: Send + 'static> Wombo<T>
[src]
fn new() -> Wombo<T>
[src]
Create a new Wombo
instance without initializing the event loop thread.
fn spawn<Fut, F>(
&self,
options: ThreadOptions,
func: F
) -> Result<(), WomboError> where
Fut: IntoFuture<Item = T, Error = ()> + 'static,
F: FnOnce(&Handle, Hooks<T>) -> Fut + Send + 'static,
[src]
&self,
options: ThreadOptions,
func: F
) -> Result<(), WomboError> where
Fut: IntoFuture<Item = T, Error = ()> + 'static,
F: FnOnce(&Handle, Hooks<T>) -> Fut + Send + 'static,
Spawn a child thread running an event loop, running func
on the child thread before the core
is run
.
To register a callback that should run when cancel
is called, but before the event loop is interrupted,
use on_cancel
here.
Panics
Panics if Core::new()
returns an error creating the event loop on the child thread.
fn id(&self) -> &Arc<String>
[src]
Read the ID for this Wombo
instance. This will not change if the backing thread exits or restarts.
fn core_thread_id(&self) -> Option<usize>
[src]
Read the thread ID of the event loop thread.
fn is_running(&self) -> bool
[src]
Whether or not the event loop thread is running.
fn cancel(&self) -> Result<(), WomboError>
[src]
Send a message to cancel the event loop thread, interrupting any futures running there.
This first triggers the callback from on_cancel
, if defined, then interrupts the event loop
and causes the spawned thread to exit. A message is then emitted to the receiver returned by
on_exit
, and resets the state of this instance so spawn
can be called again.
fn on_exit(&self) -> Result<OneshotReceiver<Option<T>>, WomboError>
[src]
Returns a oneshot receiver that resolves when the thread exits for any reason, either via the cancel
command, or otherwise.
Upon calling cancel if the caller has registered an on_cancel
callback then the receiver returned here will resolve with Some
data,
otherwise it resolves with None
if no on_cancel
callback exists.
If the future returned by func
in spawn
resolves before cancel
is called that data will be sent to the receiver returned here.
If this is called more than once the previous oneshot channel will be canceled.
Trait Implementations
impl<T: Clone + Send + 'static> Clone for Wombo<T>
[src]
fn clone(&self) -> Wombo<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Send + 'static> Debug for Wombo<T>
[src]
impl<T: Send + 'static> PartialEq for Wombo<T>
[src]
fn eq(&self, other: &Wombo<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.