MCPcopy Create free account
hub / github.com/NthTensor/Forte / scope_nesting_new_worker

Function scope_nesting_new_worker

src/scope.rs:1228–1253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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(())

Callers

nothing calls this directly

Calls 5

resize_to_availableMethod · 0.80
with_workerMethod · 0.80
scopeMethod · 0.80
depopulateMethod · 0.80
spawnMethod · 0.45

Tested by

no test coverage detected