pub struct ThreadBuilder { /* private fields */ }
Expand description
Builder for configuring and creating new threads.
This provides a comprehensive interface for setting thread parameters before spawning, with advanced options for scheduling, debugging, and resource management.
Implementations§
Source§impl ThreadBuilder
impl ThreadBuilder
Sourcepub fn stack_size_class(self, size_class: StackSizeClass) -> Self
pub fn stack_size_class(self, size_class: StackSizeClass) -> Self
Set the stack size class for the thread.
Sourcepub fn stack_size(self, size: usize) -> Self
pub fn stack_size(self, size: usize) -> Self
Set the stack size in bytes.
Sourcepub fn name<T: Into<String>>(self, name: T) -> Self
pub fn name<T: Into<String>>(self, name: T) -> Self
Set the thread name for debugging purposes.
Sourcepub fn cpu_affinity(self, mask: u64) -> Self
pub fn cpu_affinity(self, mask: u64) -> Self
Set CPU affinity mask (which CPUs this thread can run on).
Sourcepub fn stack_guard_pages(self, enabled: bool) -> Self
pub fn stack_guard_pages(self, enabled: bool) -> Self
Enable or disable stack guard pages (requires MMU feature).
Sourcepub fn stack_canary(self, enabled: bool) -> Self
pub fn stack_canary(self, enabled: bool) -> Self
Enable or disable stack canary protection.
Sourcepub fn custom_canary(self, canary: u64) -> Self
pub fn custom_canary(self, canary: u64) -> Self
Set custom stack canary value.
Sourcepub fn time_slice(self, duration: Duration) -> Self
pub fn time_slice(self, duration: Duration) -> Self
Set custom time slice duration.
Sourcepub fn critical(self, critical: bool) -> Self
pub fn critical(self, critical: bool) -> Self
Mark this thread as critical (affects scheduling priority).
Sourcepub fn preemptible(self, preemptible: bool) -> Self
pub fn preemptible(self, preemptible: bool) -> Self
Set whether this thread can be preempted.
Sourcepub fn debug_info(self, enabled: bool) -> Self
pub fn debug_info(self, enabled: bool) -> Self
Enable or disable detailed debugging information.
Sourcepub fn attributes(self, attributes: ThreadAttributes) -> Self
pub fn attributes(self, attributes: ThreadAttributes) -> Self
Set custom thread attributes.
Sourcepub fn spawn(
self,
thread_id: ThreadId,
stack_pool: &StackPool,
entry_point: fn(),
) -> Result<(Thread, JoinHandle), SpawnError>
pub fn spawn( self, thread_id: ThreadId, stack_pool: &StackPool, entry_point: fn(), ) -> Result<(Thread, JoinHandle), SpawnError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ThreadBuilder
impl RefUnwindSafe for ThreadBuilder
impl Send for ThreadBuilder
impl Sync for ThreadBuilder
impl Unpin for ThreadBuilder
impl UnwindSafe for ThreadBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more