pub struct SmolRT(/* private fields */);Expand description
The SmolRT implements AsyncRuntime trait
Implementations§
Source§impl SmolRT
impl SmolRT
pub fn new_global() -> Self
Sourcepub fn new_with_executor(executor: Arc<Executor<'static>>) -> Self
pub fn new_with_executor(executor: Arc<Executor<'static>>) -> Self
spawn coroutine with specified Executor.
§Safety
You should run block_on on this executor somewhere (self.block_on also counts), otherwise the future spawn into this executor will not run.
Trait Implementations§
Source§impl AsyncExec for SmolRT
impl AsyncExec for SmolRT
Source§fn current() -> Self
fn current() -> Self
Initiate executor using current thread.
§Safety
You should run Self::block_on() with this executor.
If spawn without a block_on() running, it’s possible
the runtime just init future without scheduling.
Source§fn multi(size: usize) -> Self
fn multi(size: usize) -> Self
Initiate executor with multiple background threads.
§NOTE
When num == 0, start threads that match cpu number
Self::block_on() is optional.
Source§fn spawn<F, R>(&self, f: F) -> Self::AsyncHandle<R>
fn spawn<F, R>(&self, f: F) -> Self::AsyncHandle<R>
Spawn a task in the background
Source§fn spawn_detach<F, R>(&self, f: F)
fn spawn_detach<F, R>(&self, f: F)
Depends on how you initialize SmolRT, spawn with executor or globally
Source§fn block_on<F, R>(&self, f: F) -> R
fn block_on<F, R>(&self, f: F) -> R
Run a future to completion on the runtime
NOTE: when initialized with an executor, will block current thread until the future returns