Struct glommio::LocalExecutor[][src]

pub struct LocalExecutor { /* fields omitted */ }

Single-threaded executor.

The executor can only be run on the thread that created it.

Examples

use glommio::LocalExecutor;

let local_ex = LocalExecutor::default();

local_ex.run(async {
    println!("Hello world!");
});

In many cases, use of LocalExecutorBuilder will provide more configuration options and more ergonomic methods. See LocalExecutorBuilder::spawn for examples.

Implementations

impl LocalExecutor[src]

pub fn id(&self) -> usize[src]

Returns a unique identifier for this Executor.

Examples

use glommio::LocalExecutor;

let local_ex = LocalExecutor::default();
println!("My ID: {}", local_ex.id());

pub fn remove_task_queue(&self, handle: TaskQueueHandle) -> Result<(), ()>[src]

Removes a task queue.

The task queue cannot be removed if there are still pending tasks.

pub fn run<T>(&self, future: impl Future<Output = T>) -> T[src]

Runs the executor until the given future completes.

Examples

use glommio::{LocalExecutor, Task};

let local_ex = LocalExecutor::default();

let res = local_ex.run(async {
    let task = Task::<usize>::local(async { 1 + 2 });
    task.await * 2
});

assert_eq!(res, 6);

Trait Implementations

impl Debug for LocalExecutor[src]

impl Default for LocalExecutor[src]

Spawns a single-threaded executor with default settings on the current thread.

This will create a executor using default parameters of LocalExecutorBuilder, if you want to further customize it, use this API instead.

Panics

Panics if creating the executor fails; use LocalExecutorBuilder::make to recover from such errors.

Examples

use glommio::LocalExecutor;

let local_ex = LocalExecutor::default();

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.