pub struct LocalExecutor { /* private fields */ }
Expand description

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

Enable or disable task stall detection at runtime

Examples
use glommio::{DefaultStallDetectionHandler, LocalExecutor};

let local_ex =
    LocalExecutor::default().detect_stalls(Some(Box::new(DefaultStallDetectionHandler {})));

Returns a unique identifier for this Executor.

Examples
use glommio::LocalExecutor;

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

Removes a task queue.

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

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 = glommio::spawn_local(async { 1 + 2 });
    task.await * 2
});

assert_eq!(res, 6);

Trait Implementations

Formats the value using the given formatter. Read more

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();

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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