()
| 1153 | let counter = &AtomicUsize::new(0); |
| 1154 | THREAD_POOL.scope(|scope| { |
| 1155 | scope.spawn(move |_: &Worker| { |
| 1156 | counter.fetch_add(1, Ordering::SeqCst); |
| 1157 | }); |
| 1158 | scope.spawn(move |_: &Worker| { |
| 1159 | counter.fetch_add(10, Ordering::SeqCst); |
| 1160 | }); |
| 1161 | }); |
| 1162 | |
| 1163 | let v = counter.load(Ordering::SeqCst); |
| 1164 | assert_eq!(v, 11); |
| 1165 | |
| 1166 | THREAD_POOL.depopulate(); |
| 1167 | } |
| 1168 | |
| 1169 | /// Test that it is possible to borrow local data within a scope, modify it, |
| 1170 | /// and then read it later. This is mostly here to ensure stuff like this |
| 1171 | /// compiles. |
| 1172 | #[test] |
| 1173 | fn scope_borrow() { |
| 1174 | static THREAD_POOL: ThreadPool = ThreadPool::new(); |
| 1175 | THREAD_POOL.resize_to_available(); |
nothing calls this directly
no test coverage detected