Struct glommio::LocalExecutorPoolBuilder [−][src]
pub struct LocalExecutorPoolBuilder { /* fields omitted */ }
Expand description
A factory to configure and create a pool of 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 Self::on_all_shards
method will take
ownership of the builder and create a PoolThreadHandles
struct which can
be used to join the executor threads.
Example
use glommio::{Local, LocalExecutorPoolBuilder};
let handles = LocalExecutorPoolBuilder::new(4)
.on_all_shards(|| async move {
let id = Local::id();
println!("hello from executor {}", id);
})
.unwrap();
handles.join_all();
Implementations
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.
Please see documentation under
LocalExecutorBuilder::spin_before_park
for details. The setting
is applied to all executors in the pool.
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.
Please see documentation under LocalExecutorBuilder::io_memory
for
details. The setting is applied to all executors in the pool.
Please see documentation under LocalExecutorBuilder::preempt_timer
for details. The setting is applied to all executors in the pool.
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
.
pub fn on_all_shards<G, F, T>(
self,
fut_gen: G
) -> Result<PoolThreadHandles<T>, ()> where
G: FnOnce() -> F + Clone + Send + 'static,
F: Future<Output = T> + 'static,
T: Send + 'static,
pub fn on_all_shards<G, F, T>(
self,
fut_gen: G
) -> Result<PoolThreadHandles<T>, ()> where
G: FnOnce() -> F + Clone + Send + 'static,
F: Future<Output = T> + 'static,
T: Send + '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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for LocalExecutorPoolBuilder
impl Send for LocalExecutorPoolBuilder
impl Sync for LocalExecutorPoolBuilder
impl Unpin for LocalExecutorPoolBuilder
impl UnwindSafe for LocalExecutorPoolBuilder
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more