()
| 1226 | value = 42; |
| 1227 | }); |
| 1228 | }); |
| 1229 | assert_eq!(value, 42); |
| 1230 | |
| 1231 | THREAD_POOL.depopulate(); |
| 1232 | } |
| 1233 | |
| 1234 | /// This is a handy future that needs to be polled repeatedly before |
| 1235 | /// resolving. |
| 1236 | /// |
| 1237 | /// Each time it is polled, it wakes itself (so it will be polled again) and |
| 1238 | /// yields. It does this until it has been polled 128 times. |
| 1239 | /// |
| 1240 | /// This lets us test the behavior of scopes for sleeping tasks, to ensure |
| 1241 | /// we do not return from the scope while tasks are still pending. |
| 1242 | #[derive(Default)] |
| 1243 | struct CountFuture { |
| 1244 | /// The number of times the future has been polled. |
| 1245 | count: usize, |
| 1246 | } |
| 1247 | |
| 1248 | impl Future for CountFuture { |
| 1249 | type Output = (); |
| 1250 | |
| 1251 | fn poll( |
| 1252 | mut self: Pin<&mut Self>, |
| 1253 | cx: &mut Context<'_>, |
| 1254 | ) -> Poll<Self::Output> { |
| 1255 | if self.count == 128 { |
| 1256 | Poll::Ready(()) |
nothing calls this directly
no test coverage detected