Struct glommio::LocalExecutorPoolBuilder[][src]

pub struct LocalExecutorPoolBuilder { /* fields omitted */ }

A factory to configure and create a pool of LocalExecutors

The LocalExecutorPoolBuilder allows creating a pool of LocalExecutors, which can be used in order to configure the properties of the LocalExecutors. Configuration methods apply their settings to all LocalExecutors 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]

pub fn new(nr_shards: usize) -> Self[src]

Generates the base configuration for spawning a pool of LocalExecutors, from which configuration methods can be chained. The method’s only argument sets the number of LocalExecutors 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 LocalExecutors 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]

Spawn a pool of LocalExecutors 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

impl Debug for LocalExecutorPoolBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.