Struct glommio::LocalExecutorPoolBuilder [−][src]
pub struct LocalExecutorPoolBuilder { /* fields omitted */ }
A factory to configure and create a pool of LocalExecutor
s
The LocalExecutorPoolBuilder
allows creating a pool of LocalExecutor
s,
which can be used in order to configure the properties of the
LocalExecutor
s. Configuration methods apply their settings to all
LocalExecutor
s in the pool unless otherwise specified.
Methods can be chained on the builder in order to configure it.
The LocalExecutorPoolBuilder::on_all_shards
method will take ownership
of the builder and create a PoolThreadHandles
struct which can be used
to join the executor threads.
Implementations
impl LocalExecutorPoolBuilder
[src]
impl LocalExecutorPoolBuilder
[src]pub fn new(nr_shards: usize) -> Self
[src]
Generates the base configuration for spawning a pool of
LocalExecutor
s, from which configuration methods can be chained.
The method’s only argument sets the number of LocalExecutor
s to
spawn.
pub fn spin_before_park(self, spin: Duration) -> Self
[src]
Please see documentation under
LocalExecutorBuilder::spin_before_park
for details. The setting
is applied to all executors in the pool.
pub fn name(self, name: &str) -> Self
[src]
Please see documentation under LocalExecutorBuilder::name
for
details. The setting is applied to all executors in the pool. Note
that when a thread is spawned, the name
is combined with a hyphen
and numeric id (e.g. myname-1
) such that each thread has a unique
name.
pub fn io_memory(self, io_memory: usize) -> Self
[src]
Please see documentation under LocalExecutorBuilder::io_memory
for
details. The setting is applied to all executors in the pool.
pub fn preempt_timer(self, dur: Duration) -> Self
[src]
Please see documentation under LocalExecutorBuilder::preempt_timer
for details. The setting is applied to all executors in the pool.
pub fn placement(self, p: Placement) -> Self
[src]
This method sets the Placement
policy by which LocalExecutor
s
are bound to the machine’s hardware topology (i.e. which CPUs to
use). The default is Placement::Unbound
.
#[must_use = "This spawns executors on multiple threads, so you may need to call \ `PoolThreadHandles::join_all()` to keep the main thread alive"]pub fn on_all_shards<G, F, T>(self, fut_gen: G) -> PoolThreadHandles where
G: FnOnce() -> F + Clone + Send + 'static,
F: Future<Output = T> + 'static,
[src]
G: FnOnce() -> F + Clone + Send + 'static,
F: Future<Output = T> + 'static,
Spawn a pool of LocalExecutor
s in a new thread according to the
Placement
policy, which is Unbound
by default.
This method is the pool equivalent of LocalExecutorBuilder::spawn
.
The method takes a closure fut_gen
which will be called on each new
thread to obtain the Future
to be executed there.
Panics
The newly spawned thread panics if creating the executor fails. If you need more fine-grained error handling consider initializing those entities manually.
Example
use glommio::{Local, LocalExecutorPoolBuilder}; let handles = LocalExecutorPoolBuilder::new(4).on_all_shards(|| async move { let id = Local::id(); println!("hello from executor {}", id); }); handles.join_all();
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for LocalExecutorPoolBuilder
impl RefUnwindSafe for LocalExecutorPoolBuilder
impl Send for LocalExecutorPoolBuilder
impl Send for LocalExecutorPoolBuilder
impl Sync for LocalExecutorPoolBuilder
impl Sync for LocalExecutorPoolBuilder
impl Unpin for LocalExecutorPoolBuilder
impl Unpin for LocalExecutorPoolBuilder
impl UnwindSafe for LocalExecutorPoolBuilder
impl UnwindSafe for LocalExecutorPoolBuilder