task: fix wording with 'unsend' (#5452)

This commit is contained in:
Tim de Jager
2023-02-14 12:44:05 +00:00
committed by GitHub
parent d1da6c20d8
commit 28d6f4d509
+14 -14
View File
@@ -34,14 +34,14 @@ cfg_rt! {
/// async fn main() {
/// // `Rc` does not implement `Send`, and thus may not be sent between
/// // threads safely.
/// let unsend_data = Rc::new("my unsend data...");
/// let nonsend_data = Rc::new("my nonsend data...");
///
/// let unsend_data = unsend_data.clone();
/// // Because the `async` block here moves `unsend_data`, the future is `!Send`.
/// let nonsend_data = nonsend_data.clone();
/// // Because the `async` block here moves `nonsend_data`, the future is `!Send`.
/// // Since `tokio::spawn` requires the spawned future to implement `Send`, this
/// // will not compile.
/// tokio::spawn(async move {
/// println!("{}", unsend_data);
/// println!("{}", nonsend_data);
/// // ...
/// }).await.unwrap();
/// }
@@ -60,18 +60,18 @@ cfg_rt! {
///
/// #[tokio::main]
/// async fn main() {
/// let unsend_data = Rc::new("my unsend data...");
/// let nonsend_data = Rc::new("my nonsend data...");
///
/// // Construct a local task set that can run `!Send` futures.
/// let local = task::LocalSet::new();
///
/// // Run the local task set.
/// local.run_until(async move {
/// let unsend_data = unsend_data.clone();
/// let nonsend_data = nonsend_data.clone();
/// // `spawn_local` ensures that the future is spawned on the local
/// // task set.
/// task::spawn_local(async move {
/// println!("{}", unsend_data);
/// println!("{}", nonsend_data);
/// // ...
/// }).await.unwrap();
/// }).await;
@@ -94,18 +94,18 @@ cfg_rt! {
///
/// #[tokio::main]
/// async fn main() {
/// let unsend_data = Rc::new("world");
/// let nonsend_data = Rc::new("world");
/// let local = task::LocalSet::new();
///
/// let unsend_data2 = unsend_data.clone();
/// let nonsend_data2 = nonsend_data.clone();
/// local.spawn_local(async move {
/// // ...
/// println!("hello {}", unsend_data2)
/// println!("hello {}", nonsend_data2)
/// });
///
/// local.spawn_local(async move {
/// time::sleep(time::Duration::from_millis(100)).await;
/// println!("goodbye {}", unsend_data)
/// println!("goodbye {}", nonsend_data)
/// });
///
/// // ...
@@ -309,15 +309,15 @@ cfg_rt! {
///
/// #[tokio::main]
/// async fn main() {
/// let unsend_data = Rc::new("my unsend data...");
/// let nonsend_data = Rc::new("my nonsend data...");
///
/// let local = task::LocalSet::new();
///
/// // Run the local task set.
/// local.run_until(async move {
/// let unsend_data = unsend_data.clone();
/// let nonsend_data = nonsend_data.clone();
/// task::spawn_local(async move {
/// println!("{}", unsend_data);
/// println!("{}", nonsend_data);
/// // ...
/// }).await.unwrap();
/// }).await;