pub struct RuntimeBuilder<'w> { /* private fields */ }Expand description
Builder for configuring a Runtime.
§Examples
use nexus_async_rt::*;
use nexus_slab::byte::unbounded::Slab;
let mut world = nexus_rt::WorldBuilder::new().build();
let slab = unsafe { Slab::<256>::with_chunk_capacity(64) };
let mut rt = Runtime::builder(&mut world)
.tasks_per_cycle(128)
.slab_unbounded(slab)
.signal_handlers(true)
.build();Implementations§
Source§impl<'w> RuntimeBuilder<'w>
impl<'w> RuntimeBuilder<'w>
Sourcepub fn tasks_per_cycle(self, limit: usize) -> Self
pub fn tasks_per_cycle(self, limit: usize) -> Self
Maximum tasks polled per cycle before yielding to check IO. Default: 64.
Sourcepub fn event_interval(self, n: u32) -> Self
pub fn event_interval(self, n: u32) -> Self
Number of loop iterations between non-blocking IO driver polls. Default: 61 (matches tokio’s heuristic).
Every event_interval iterations the runtime does a non-blocking
epoll_wait(0) to check for socket events, even if tasks are
ready. Lower values improve IO responsiveness at the cost of
more syscalls; higher values favor task throughput.
Sourcepub fn cross_thread_drain_limit(self, limit: usize) -> Self
pub fn cross_thread_drain_limit(self, limit: usize) -> Self
Maximum cross-thread wakes drained per poll cycle. Default: unlimited.
Caps how many tasks woken from other threads are moved into the local ready queue per iteration. Prevents a firehose of cross-thread wakes from starving local tasks and IO. Remaining wakes are drained on the next iteration.
Sourcepub fn queue_capacity(self, cap: usize) -> Self
pub fn queue_capacity(self, cap: usize) -> Self
Pre-allocated capacity for internal queues. Default: 64.
Sourcepub fn event_capacity(self, cap: usize) -> Self
pub fn event_capacity(self, cap: usize) -> Self
Maximum IO events processed per epoll cycle. Default: 1024.
Sourcepub fn token_capacity(self, cap: usize) -> Self
pub fn token_capacity(self, cap: usize) -> Self
Initial number of IO source slots. Default: 64.
Sourcepub fn signal_handlers(self, enable: bool) -> Self
pub fn signal_handlers(self, enable: bool) -> Self
Install SIGTERM/SIGINT signal handlers. Default: false.
Sourcepub fn slab_unbounded<const S: usize>(self, slab: Slab<S>) -> Self
pub fn slab_unbounded<const S: usize>(self, slab: Slab<S>) -> Self
Hand off a growable (unbounded) slab for spawn_slab.
S is the total slot size in bytes. The task header uses 72 bytes,
so Slab<256> gives 184 bytes for the future. Most async IO
futures are 128–256 bytes — Slab<256> or Slab<512> covers
the common cases.
The slab grows by allocating new chunks when full. No task spawn will ever fail due to capacity.
§Examples
use nexus_slab::byte::unbounded::Slab;
// SAFETY: single-threaded runtime.
let slab = unsafe { Slab::<256>::with_chunk_capacity(64) };
let mut rt = Runtime::builder(&mut world)
.slab_unbounded(slab)
.build();Sourcepub fn slab_bounded<const S: usize>(self, slab: Slab<S>) -> Self
pub fn slab_bounded<const S: usize>(self, slab: Slab<S>) -> Self
Hand off a fixed-capacity (bounded) slab for spawn_slab.
S is the total slot size in bytes. The slab has a fixed number
of slots — spawn_slab panics if the slab is full. Use this
when you want deterministic memory usage and know the maximum
number of concurrent hot-path tasks.
§Examples
use nexus_slab::byte::bounded::Slab;
// SAFETY: single-threaded runtime.
let slab = unsafe { Slab::<256>::with_capacity(64) };
let mut rt = Runtime::builder(&mut world)
.slab_bounded(slab)
.build();