[−][src]Function kayrx::karx::block
pub fn block<F, T>(f: F) -> JoinKarx<T> where
F: FnOnce() -> T + Send + 'static,
T: Send + 'static,
Spawns a blocking Karx.
The Karx will be spawned onto a thread pool specifically dedicated to blocking Karx. This is useful to prevent long-running synchronous operations from blocking the main futures executor.
See also: karx::exec
, karx::spawn
.
Examples
Basic usage:
use kayrx::karx; karx::block(|| { println!("long-running task here"); }) .await;