(f: F)
| 1172 | nonsend_fifo_queue: Arc::new(SegQueue::new()), |
| 1173 | rng: XorShift64Star::new(), |
| 1174 | last_promote_tick: Cell::new(0), |
| 1175 | join_start: Cell::new(0), |
| 1176 | tree_seen: Cell::new(false), |
| 1177 | search_until: Cell::new(0), |
| 1178 | heartbeat_ticks: time::duration_to_ticks(time::HEARTBEAT), |
| 1179 | spin_ticks: time::duration_to_ticks(Worker::SPIN_DURATION), |
| 1180 | _phantom: PhantomData, |
| 1181 | }; |
| 1182 | |
| 1183 | // Guard against any unexpected panics, so that the pointer is not left |
| 1184 | // dangling. |
| 1185 | let abort_guard = unwind::AbortOnDrop; |
| 1186 | |
| 1187 | // Swap the local pointer to point to the newly allocated worker. |
| 1188 | let outer_ptr = WORKER_PTR.with(|ptr| ptr.replace(&worker)); |
| 1189 | |
| 1190 | // Run the function within the context created by the worker pointer, |
| 1191 | // and pass in a worker reference directly. |
| 1192 | let result = unwind::halt_unwinding(|| f(&worker)); |
| 1193 | |
| 1194 | // Indicate that we want to resign. |
| 1195 | worker |
| 1196 | .thread_pool |
| 1197 | .wants_to_resign |
| 1198 | .fetch_or(1 << worker.member_index, Ordering::Relaxed); |
| 1199 | |
| 1200 | // Wait for all local work to complete, and our resignation to be |
| 1201 | // accepted. |
nothing calls this directly
no outgoing calls
no test coverage detected