pub struct DispatcherBuilder { /* private fields */ }dispatcher only.Expand description
A builder for Dispatcher.
Implementations§
Source§impl DispatcherBuilder
impl DispatcherBuilder
Sourcepub fn new() -> DispatcherBuilder
pub fn new() -> DispatcherBuilder
Create a builder with default settings.
Sourcepub fn concurrent(self, concurrent: bool) -> DispatcherBuilder
pub fn concurrent(self, concurrent: bool) -> DispatcherBuilder
If execute tasks concurrently. Default to be true.
When set to false, tasks are executed sequentially without any
concurrency within the thread.
Sourcepub fn worker_threads(self, nthreads: NonZero<usize>) -> DispatcherBuilder
pub fn worker_threads(self, nthreads: NonZero<usize>) -> DispatcherBuilder
Set the number of worker threads of the dispatcher. The default value is the CPU number. If the CPU number could not be retrieved, the default value is 1.
Sourcepub fn stack_size(self, s: usize) -> DispatcherBuilder
pub fn stack_size(self, s: usize) -> DispatcherBuilder
Set the size of stack of the worker threads.
Sourcepub fn block_signals(self, block_signals: bool) -> DispatcherBuilder
pub fn block_signals(self, block_signals: bool) -> DispatcherBuilder
Block standard signals on worker threads.
Default to true. When enabled, SIGINT, SIGTERM, SIGQUIT,
SIGHUP, SIGUSR1, SIGUSR2, and SIGPIPE are masked on worker
threads.
This option only has effect on Unix systems. On non-Unix systems, this method does nothing.
On Unix systems, when Dispatcher spawns worker threads, they inherit
the parent thread’s signal mask. By default, SIGINT (Ctrl-C) and other
signals can be delivered to any thread in the process. If a worker
thread receives the signal before the async signal handler is polled on
the main thread, the default signal handler runs (terminating the
process) instead of the compio signal handler.
This is a well-known issue in multi-threaded Unix applications and requires explicit signal masking.
Sourcepub fn thread_affinity(
self,
f: impl FnMut(usize) -> HashSet<usize> + 'static,
) -> DispatcherBuilder
pub fn thread_affinity( self, f: impl FnMut(usize) -> HashSet<usize> + 'static, ) -> DispatcherBuilder
Set the thread affinity for the dispatcher.
Sourcepub fn thread_names(
self,
f: impl FnMut(usize) -> String + 'static,
) -> DispatcherBuilder
pub fn thread_names( self, f: impl FnMut(usize) -> String + 'static, ) -> DispatcherBuilder
Provide a function to assign names to the worker threads.
Sourcepub fn proactor_builder(self, builder: ProactorBuilder) -> DispatcherBuilder
pub fn proactor_builder(self, builder: ProactorBuilder) -> DispatcherBuilder
Set the proactor builder for the inner runtimes.
Sourcepub fn build(self) -> Result<Dispatcher, Error>
pub fn build(self) -> Result<Dispatcher, Error>
Build the Dispatcher.
Trait Implementations§
Source§impl Default for DispatcherBuilder
impl Default for DispatcherBuilder
Source§fn default() -> DispatcherBuilder
fn default() -> DispatcherBuilder
Auto Trait Implementations§
impl Freeze for DispatcherBuilder
impl !RefUnwindSafe for DispatcherBuilder
impl !Send for DispatcherBuilder
impl !Sync for DispatcherBuilder
impl Unpin for DispatcherBuilder
impl UnsafeUnpin for DispatcherBuilder
impl !UnwindSafe for DispatcherBuilder
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more