Struct ste::Builder[][src]

pub struct Builder { /* fields omitted */ }

The builder for a Thread which can be configured a bit more.

Implementations

impl Builder[src]

pub fn new() -> Self[src]

Construct a new builder.

pub fn with_tokio(self) -> Self[src]

Enable tokio support.

Examples

let thread = ste::Builder::new().with_tokio().build()?;

thread.submit_async(async {
    tokio::time::sleep(std::time::Duration::from_secs(1)).await;
    println!("Hello World!");
});

thread.join();

pub fn prelude<P>(self, prelude: P) -> Self where
    P: Fn() + Send + 'static, 
[src]

Configure a prelude to the Thread. This is code that will run just as the thread is spinning up.

Examples

fn say_hello(main_thread: std::thread::ThreadId) {
    println!("Hello from the prelude!");
    assert_ne!(main_thread, std::thread::current().id());
}

let main_thread = std::thread::current().id();

let thread = ste::Builder::new().prelude(move || say_hello(main_thread)).build();

pub fn build(self) -> Result<Thread>[src]

Construct the background thread.

Examples

let thread = ste::Builder::new().build()?;
thread.join();

Auto Trait Implementations

impl !RefUnwindSafe for Builder

impl Send for Builder

impl !Sync for Builder

impl Unpin for Builder

impl !UnwindSafe for Builder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.