pub struct RThreadBuilder {
stack_size: usize,
name: Option<String>,
}Expand description
Builder for spawning pure-Rust threads with a legacy R-sized stack.
This builder is always available and configures threads with stack sizes suitable for stack-heavy Rust workloads (8 MiB default, vs Rust’s 2 MiB default).
When the nonapi feature is enabled, spawned threads also automatically
disable R’s stack checking via StackCheckGuard. That changes only the
stack-address check and does not make R API calls from the thread safe.
§Example
use miniextendr_api::thread::RThreadBuilder;
let handle = RThreadBuilder::new()
.stack_size(16 * 1024 * 1024) // 16 MiB
.name("r-worker".to_string())
.spawn(expensive_pure_rust_computation)?;Fields§
§stack_size: usize§name: Option<String>Implementations§
Source§impl RThreadBuilder
impl RThreadBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with default settings.
Default stack size is DEFAULT_R_STACK_SIZE (8 MiB).
Sourcepub fn stack_size(self, size: usize) -> Self
pub fn stack_size(self, size: usize) -> Self
Set the stack size for the thread.
The default is 8 MiB, matching the legacy R-sized configuration rather than Rust’s typical 2 MiB spawned-thread default.
Sourcepub fn spawn<F, T>(self, f: F) -> Result<JoinHandle<T>>
pub fn spawn<F, T>(self, f: F) -> Result<JoinHandle<T>>
Spawn the thread with the configured settings.
With nonapi feature: automatically disables R’s stack checking.
Without nonapi feature: just spawns with the configured stack size.
Sourcepub fn spawn_join<F, T>(self, f: F) -> Result<T>
pub fn spawn_join<F, T>(self, f: F) -> Result<T>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RThreadBuilder
impl RefUnwindSafe for RThreadBuilder
impl Send for RThreadBuilder
impl Sync for RThreadBuilder
impl Unpin for RThreadBuilder
impl UnsafeUnpin for RThreadBuilder
impl UnwindSafe for RThreadBuilder
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
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes