Created
July 5, 2020 10:34
-
-
Save narodnik/6ddfa64cd2cc10b2dcf60623cd49ddeb 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
impl<T: Send + 'static> Task<T> { | |
/// Spawns a future onto the work-stealing executor. | |
/// | |
/// This future may be stolen and polled by any thread calling [`run()`]. | |
/// | |
/// # Examples | |
/// | |
/// ``` | |
/// use smol::Task; | |
/// | |
/// # smol::run(async { | |
/// let task = Task::spawn(async { 1 + 2 }); | |
/// assert_eq!(task.await, 3); | |
/// # }); | |
/// ``` | |
/// | |
/// [`run()`]: `crate::run()` | |
pub fn spawn(future: impl Future<Output = T> + Send + 'static) -> Task<T> { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment