pub struct Runtime { /* private fields */ }Expand description
The async runtime for ntex.
This is a thread-local runtime and cannot be sent to other threads.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn builder() -> RuntimeBuilder
pub fn builder() -> RuntimeBuilder
Creates a runtime builder.
Sourcepub fn with_current<T, F>(f: F) -> T
pub fn with_current<T, F>(f: F) -> T
Runs a closure with the runtime active on the current thread.
§Panics
Panics if no runtime is active on the current thread.
Sourcepub fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output> ⓘwhere
F: Future + 'static,
pub fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output> ⓘwhere
F: Future + 'static,
Spawns a new asynchronous task, returning a JoinHandle for it.
Spawning a task enables the task to execute concurrently to other tasks. There is no guarantee that a spawned task will execute to completion.
Sourcepub unsafe fn spawn_unchecked<F>(
&self,
future: F,
) -> JoinHandle<<F as Future>::Output> ⓘwhere
F: Future,
pub unsafe fn spawn_unchecked<F>(
&self,
future: F,
) -> JoinHandle<<F as Future>::Output> ⓘwhere
F: Future,
Spawns a new asynchronous task, returning a JoinHandle for it.
§Safety
The caller should ensure the captured lifetime is long enough.
Sourcepub fn awake(&self)
pub fn awake(&self)
Marks the runtime as awake.
Drivers call this after returning from a blocking wait, before handling
events that wake tasks. Tasks scheduled from the runtime thread do not
notify the driver until poll finds no more tasks to run,
the driver must call poll before blocking again.
Sourcepub fn poll(&self) -> PollResult
pub fn poll(&self) -> PollResult
Polls the runtime and runs scheduled tasks.