Skip to content

Instantly share code, notes, and snippets.

@scrogson
Created December 12, 2019 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scrogson/2247e261561a0d52e5a46a08677ac8d5 to your computer and use it in GitHub Desktop.
Save scrogson/2247e261561a0d52e5a46a08677ac8d5 to your computer and use it in GitHub Desktop.
use std::future::Future;
use tokio::runtime::{Builder, Runtime};
use tokio::task::JoinHandle;
lazy_static::lazy_static! {
static ref TOKIO: Runtime = Builder::new()
.threaded_scheduler()
.build()
.expect("Franz.Native: Failed to start tokio runtime");
}
pub fn spawn<T>(task: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
TOKIO.spawn(task)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment