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]
P: Fn() + Send + 'static,
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]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,