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

Function scope_nesting

src/scope.rs:1205–1224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1203 });
1204 scope.spawn(|_: &Worker| {
1205 counter.fetch_add(1, Ordering::Relaxed);
1206 scope.spawn(|_: &Worker| {
1207 counter.fetch_add(1, Ordering::Relaxed);
1208 });
1209 });
1210 });
1211 assert_eq!(counter.load(Ordering::Relaxed), 4);
1212
1213 THREAD_POOL.depopulate();
1214 }
1215
1216 /// Tests that we can spawn futures onto the thread pool and that they can
1217 /// borrow data as expected.
1218 #[test]
1219 fn scope_future() {
1220 static THREAD_POOL: ThreadPool = ThreadPool::new();
1221 THREAD_POOL.resize_to_available();
1222
1223 let mut value = 0;
1224 THREAD_POOL.scope(|scope| {
1225 scope.spawn(async {
1226 value = 42;
1227 });

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected