aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-futures/src/yield_now.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/embassy-futures/src/yield_now.rs b/embassy-futures/src/yield_now.rs
index bb3c67d17..4d4e535f2 100644
--- a/embassy-futures/src/yield_now.rs
+++ b/embassy-futures/src/yield_now.rs
@@ -9,10 +9,16 @@ use core::task::{Context, Poll};
9/// hold, while still allowing other tasks to run concurrently (not monopolizing 9/// hold, while still allowing other tasks to run concurrently (not monopolizing
10/// the executor thread). 10/// the executor thread).
11/// 11///
12/// ```rust,no_run 12/// ```rust
13/// # use embassy_futures::{block_on, yield_now};
14/// # async fn test_fn() {
15/// # let mut iter_count: u32 = 0;
16/// # let mut some_condition = || { iter_count += 1; iter_count > 10 };
13/// while !some_condition() { 17/// while !some_condition() {
14/// yield_now().await; 18/// yield_now().await;
15/// } 19/// }
20/// # }
21/// # block_on(test_fn());
16/// ``` 22/// ```
17/// 23///
18/// The downside is this will spin in a busy loop, using 100% of the CPU, while 24/// The downside is this will spin in a busy loop, using 100% of the CPU, while