pub struct RThreadBuilder {
stack_size: usize,
name: Option<String>,
}Expand description
Builder for spawning threads with R-appropriate stack sizes.
This builder is always available and configures threads with stack sizes suitable for R 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, allowing R API calls
from the thread.
§Example
use miniextendr_api::thread::RThreadBuilder;
let handle = RThreadBuilder::new()
.stack_size(16 * 1024 * 1024) // 16 MiB
.name("r-worker".to_string())
.spawn(|| {
// With `nonapi`: R API calls safe here
// Without `nonapi`: Just a thread with correct stack size
})?;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.
R typically requires more stack space than Rust’s default 2 MiB. The default is 8 MiB to match typical R installations.
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.