()
| 1174 | static THREAD_POOL: ThreadPool = ThreadPool::new(); |
| 1175 | THREAD_POOL.resize_to_available(); |
| 1176 | |
| 1177 | let mut string = "a"; |
| 1178 | THREAD_POOL.scope(|scope| { |
| 1179 | scope.spawn(|_: &Worker| { |
| 1180 | string = "b"; |
| 1181 | }); |
| 1182 | }); |
| 1183 | assert_eq!(string, "b"); |
| 1184 | |
| 1185 | THREAD_POOL.depopulate(); |
| 1186 | } |
| 1187 | |
| 1188 | /// Test that it is possible to borrow local data immutably within deeply |
| 1189 | /// nested scopes. This is also mostly here to ensure stuff like this |
| 1190 | /// compiles. |
| 1191 | #[test] |
| 1192 | fn scope_borrow_twice() { |
| 1193 | static THREAD_POOL: ThreadPool = ThreadPool::new(); |
| 1194 | THREAD_POOL.resize_to_available(); |
| 1195 | |
| 1196 | let counter = AtomicU8::new(0); |
| 1197 | THREAD_POOL.scope(|scope| { |
| 1198 | scope.spawn(|_: &Worker| { |
| 1199 | counter.fetch_add(1, Ordering::Relaxed); |
| 1200 | scope.spawn(|_: &Worker| { |
| 1201 | counter.fetch_add(1, Ordering::Relaxed); |
| 1202 | }); |
| 1203 | }); |
| 1204 | scope.spawn(|_: &Worker| { |
| 1205 | counter.fetch_add(1, Ordering::Relaxed); |
nothing calls this directly
no test coverage detected