pub enum TokioExec {
Runtime(Arc<Runtime>),
Handle(Handle),
}Expand description
The main struct for tokio runtime IO, assign this type to AsyncIO trait when used.
Variants§
Implementations§
Source§impl TokioExec
impl TokioExec
Sourcepub fn new_with_runtime(rt: Runtime) -> Self
pub fn new_with_runtime(rt: Runtime) -> Self
Capture a runtime
pub fn new_multi_thread(workers: usize) -> Self
pub fn new_current_thread() -> Self
Sourcepub fn new_with_handle(handle: Handle) -> Self
pub fn new_with_handle(handle: Handle) -> Self
Only capture a runtime handle. Should acquire with
async { Handle::current() }
Trait Implementations§
Source§impl AsyncExec for TokioExec
impl AsyncExec for TokioExec
Source§fn spawn<F, R>(&self, f: F) -> TokioJoinHandle<R> ⓘ
fn spawn<F, R>(&self, f: F) -> TokioJoinHandle<R> ⓘ
Spawn a task in the background, returning a handle to await its result
Source§fn spawn_detach<F, R>(&self, f: F)
fn spawn_detach<F, R>(&self, f: F)
Spawn a task and detach it (no handle returned)
Source§fn block_on<F, R>(&self, f: F) -> Rwhere
F: Future<Output = R>,
R: 'static,
fn block_on<F, R>(&self, f: F) -> Rwhere
F: Future<Output = R>,
R: 'static,
Run a future to completion on the runtime
type AsyncJoiner<R: Send> = TokioJoinHandle<R>
type ThreadJoiner<R: Send> = TokioThreadHandle<R>
Source§fn spawn_blocking<F, R>(&self, f: F) -> TokioThreadHandle<R> ⓘ
fn spawn_blocking<F, R>(&self, f: F) -> TokioThreadHandle<R> ⓘ
Run blocking code in a background thread pool, and return an async join handle Read more
Auto Trait Implementations§
impl Freeze for TokioExec
impl RefUnwindSafe for TokioExec
impl Send for TokioExec
impl Sync for TokioExec
impl Unpin for TokioExec
impl UnsafeUnpin for TokioExec
impl UnwindSafe for TokioExec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more