Created
December 12, 2019 23:53
-
-
Save scrogson/2247e261561a0d52e5a46a08677ac8d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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