Struct glommio::LocalExecutor
source · [−]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
sourceimpl LocalExecutor
impl LocalExecutor
sourcepub fn detect_stalls(
&self,
handler: Option<Box<dyn StallDetectionHandler + 'static>>
) -> Result<(), ()>
pub fn detect_stalls(
&self,
handler: Option<Box<dyn StallDetectionHandler + 'static>>
) -> Result<(), ()>
Enable or disable task stall detection at runtime
Examples
use glommio::{DefaultStallDetectionHandler, LocalExecutor};
let local_ex =
LocalExecutor::default().detect_stalls(Some(Box::new(DefaultStallDetectionHandler {})));sourcepub fn id(&self) -> usize
pub fn id(&self) -> usize
Returns a unique identifier for this Executor.
Examples
use glommio::LocalExecutor;
let local_ex = LocalExecutor::default();
println!("My ID: {}", local_ex.id());sourcepub fn remove_task_queue(&self, handle: TaskQueueHandle) -> Result<(), ()>
pub fn remove_task_queue(&self, handle: TaskQueueHandle) -> Result<(), ()>
Removes a task queue.
The task queue cannot be removed if there are still pending tasks.
sourcepub fn run<T>(&self, future: impl Future<Output = T>) -> T
pub fn run<T>(&self, future: impl Future<Output = T>) -> T
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
sourceimpl Debug for LocalExecutor
impl Debug for LocalExecutor
sourceimpl Default for LocalExecutor
impl Default for LocalExecutor
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
impl !RefUnwindSafe for LocalExecutor
impl !Send for LocalExecutor
impl !Sync for LocalExecutor
impl Unpin for LocalExecutor
impl !UnwindSafe for LocalExecutor
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more