Merge pull request #17 from stjepang/taiki-e/doc-link

Fix doc links
This commit is contained in:
Stjepan Glavina 2020-04-24 06:03:17 -07:00 committed by GitHub
commit 4f24a6df68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -18,7 +18,7 @@ use crate::context;
/// This function polls the future in a loop, parking the current thread after each step to wait
/// until its waker is woken.
///
/// Unlike [`run`], it does not run executors or poll the reactor!
/// Unlike [`run()`], it does not run executors or poll the reactor!
///
/// You can think of it as the easiest and most efficient way of turning an async operation into a
/// blocking operation.
@ -40,6 +40,8 @@ use crate::context;
/// Timer::after(Duration::from_secs(1)).await;
/// })
/// ```
///
/// [`run()`]: crate::run()
pub fn block_on<T>(future: impl Future<Output = T>) -> T {
thread_local! {
// Parker and waker associated with the current thread.

View File

@ -49,6 +49,8 @@ pub(crate) type Runnable = async_task::Task<()>;
/// assert_eq!(task.await, 3);
/// # });
/// ```
///
/// [`run()`]: crate::run()
#[must_use = "tasks get canceled when dropped, use `.detach()` to run them in the background"]
#[derive(Debug)]
pub struct Task<T>(pub(crate) Option<async_task::JoinHandle<T, ()>>);
@ -68,6 +70,8 @@ impl<T: 'static> Task<T> {
/// assert_eq!(task.await, 3);
/// # })
/// ```
///
/// [`run()`]: crate::run()
pub fn local(future: impl Future<Output = T> + 'static) -> Task<T> {
ThreadLocalExecutor::spawn(future)
}
@ -88,6 +92,8 @@ impl<T: Send + 'static> Task<T> {
/// assert_eq!(task.await, 3);
/// # });
/// ```
///
/// [`run()`]: crate::run()
pub fn spawn(future: impl Future<Output = T> + Send + 'static) -> Task<T> {
WorkStealingExecutor::get().spawn(future)
}

View File

@ -20,6 +20,8 @@
//! Of course, work-stealing still causes contention in some cases, but much less often.
//!
//! More about work stealing: https://en.wikipedia.org/wiki/Work_stealing
//!
//! [`run()`]: crate::run()
use std::cell::Cell;
use std::future::Future;