[−][src]Struct glommio::prelude::LocalExecutor
Single-threaded executor.
The executor can only be run on the thread that created it.
Examples
use glommio::LocalExecutor; let local_ex = LocalExecutor::make_default(); local_ex.run(async { println!("Hello world!"); });
Implementations
impl LocalExecutor
[src]
pub fn make_default() -> 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::make_default();
pub fn id(&self) -> usize
[src]
Returns a unique identifier for this Executor.
Examples
use glommio::LocalExecutor; let local_ex = LocalExecutor::make_default(); println!("My ID: {}", local_ex.id());
pub fn create_task_queue<S>(
&self,
shares: Shares,
latency: Latency,
name: S
) -> TaskQueueHandle where
S: Into<String>,
[src]
&self,
shares: Shares,
latency: Latency,
name: S
) -> TaskQueueHandle where
S: Into<String>,
Creates a task queue in the executor.
Returns an opaque handler that can later be used to launch tasks into that queue with spawn_into
Examples
use std::time::Duration; use glommio::{LocalExecutor, Latency, Shares}; let local_ex = LocalExecutor::make_default(); let task_queue = local_ex.create_task_queue(Shares::default(), Latency::Matters(Duration::from_secs(1)), "my_tq"); let task = local_ex.spawn_into(async { println!("Hello world"); }, task_queue).expect("failed to spawn task");
pub fn remove_task_queue(
&self,
handle: TaskQueueHandle
) -> Result<(), Box<dyn Error>>
[src]
&self,
handle: TaskQueueHandle
) -> Result<(), Box<dyn Error>>
Removes a task queue.
The task queue cannot be removed if there are still pending tasks.
pub fn spawn<T: 'static>(
&self,
future: impl Future<Output = T> + 'static
) -> Task<T>ⓘ
[src]
&self,
future: impl Future<Output = T> + 'static
) -> Task<T>ⓘ
Spawns a task onto the executor.
Examples
use glommio::LocalExecutor; let local_ex = LocalExecutor::make_default(); let task = local_ex.spawn(async { println!("Hello world"); });
pub fn spawn_into<T, F>(
&self,
future: F,
handle: TaskQueueHandle
) -> Result<Task<T>, QueueNotFoundError> where
T: 'static,
F: Future<Output = T> + 'static,
[src]
&self,
future: F,
handle: TaskQueueHandle
) -> Result<Task<T>, QueueNotFoundError> where
T: 'static,
F: Future<Output = T> + 'static,
Spawns a task onto the executor, to be run at a particular task queue indicated by the TaskQueueHandle
Examples
use glommio::{LocalExecutor, Shares}; let local_ex = LocalExecutor::make_default(); let handle = local_ex.create_task_queue(Shares::default(), glommio::Latency::NotImportant, "test_queue"); let task = local_ex.spawn_into(async { println!("Hello world"); }, handle).expect("failed to spawn task");
pub fn run<T>(&self, future: impl Future<Output = T>) -> T
[src]
Runs the executor until the given future completes.
Examples
use glommio::LocalExecutor; let local_ex = LocalExecutor::make_default(); let task = local_ex.spawn(async { 1 + 2 }); let res = local_ex.run(async { task.await * 2 }); assert_eq!(res, 6);
Trait Implementations
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,