Struct wasm_thread::Builder
source · [−]pub struct Builder { /* private fields */ }
Expand description
Thread factory, which can be used in order to configure the properties of a new thread.
Implementations
sourceimpl Builder
impl Builder
sourcepub fn new() -> Builder
pub fn new() -> Builder
Generates the base configuration for spawning a thread, from which configuration methods can be chained.
sourcepub fn stack_size(self, size: usize) -> Builder
pub fn stack_size(self, size: usize) -> Builder
Sets the size of the stack (in bytes) for the new thread.
sourcepub fn wasm_bindgen_shim_url(self, url: String) -> Builder
pub fn wasm_bindgen_shim_url(self, url: String) -> Builder
Sets the URL of wasm_bindgen generated shim script.
sourcepub fn spawn<F, T>(self, f: F) -> Result<JoinHandle<T>> where
F: FnOnce() -> T,
F: Send + 'static,
T: Send + 'static,
pub fn spawn<F, T>(self, f: F) -> Result<JoinHandle<T>> where
F: FnOnce() -> T,
F: Send + 'static,
T: Send + 'static,
Spawns a new thread by taking ownership of the Builder
, and returns an
[io::Result
] to its JoinHandle
.
sourcepub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> Result<JoinHandle<T>> where
F: FnOnce() -> T,
F: Send + 'a,
T: Send + 'a,
pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> Result<JoinHandle<T>> where
F: FnOnce() -> T,
F: Send + 'a,
T: Send + 'a,
Spawns a new thread without any lifetime restrictions by taking ownership
of the Builder
, and returns an [io::Result
] to its JoinHandle
.
Safety
The caller has to ensure that no references in the supplied thread closure or its return type can outlive the spawned thread’s lifetime. This can be guaranteed in two ways:
- ensure that
join
is called before any referenced data is dropped - use only types with
'static
lifetime bounds, i.e., those with no or only'static
references (bothBuilder::spawn
andspawn
enforce this property statically)
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more