pub struct Setup { /* private fields */ }Expand description
Setup a Runtime.
This type implements a builder pattern to build a Runtime. It is created
via Runtime::setup, for examples and usage see crate documentation.
Implementations
sourceimpl Setup
impl Setup
sourcepub fn with_name(self, name: String) -> Setup
pub fn with_name(self, name: String) -> Setup
Set the name of the application.
If the name is not set when the runtime is build the name of the binary called will be used.
sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Returns the application name, if set using Setup::with_name.
sourcepub fn num_threads(self, n: usize) -> Self
pub fn num_threads(self, n: usize) -> Self
Set the number of worker threads to use, defaults to one.
Most applications would want to use Setup::use_all_cores which sets
the number of threads equal to the number of CPU cores.
sourcepub fn use_all_cores(self) -> Self
pub fn use_all_cores(self) -> Self
Set the number of worker threads equal to the number of CPU cores.
This uses thread::available_parallelism, please read its
documentation for a number of caveats and platform-specific behaviour.
sourcepub const fn get_threads(&self) -> usize
pub const fn get_threads(&self) -> usize
Returns the number of worker threads to use.
See Setup::num_threads.
sourcepub const fn auto_cpu_affinity(self) -> Self
pub const fn auto_cpu_affinity(self) -> Self
Automatically set CPU affinity.
This uses pthread_setaffinity_np(3) to set the CPU affinity for each
worker thread to there own CPU core.
Thread-local workers creating sockets, such as UdpSocket or
TcpStream, will use SO_INCOMING_CPU to set the CPU affinity to
the same value as the worker’s affinity.
Notes
The is mostly useful when using Setup::use_all_cores to create a
single worker thread per CPU core.
This is currently only implementated on Linux.