(&self)
| 1460 | /// `None`. |
| 1461 | #[inline(always)] |
| 1462 | pub fn with_current<F, R>(f: F) -> R |
| 1463 | where |
| 1464 | F: FnOnce(Option<&Worker>) -> R, |
| 1465 | { |
| 1466 | let worker_ptr = WORKER_PTR.with(Cell::get); |
| 1467 | if !worker_ptr.is_null() { |
| 1468 | // SAFETY: `WORKER_PTR` is a thread-local `Cell` holding a raw |
| 1469 | // pointer to a `Worker`. It is only written to by |
| 1470 | // `Membership::activate`, which stores the address of a `Worker` |
| 1471 | // allocated within its own stack frame. Before it returns, |
| 1472 | // `activate` restores the previous value of `WORKER_PTR` (and it |
| 1473 | // aborts on panic, so this reset is guaranteed to occur). So the |
| 1474 | // `WORKER_PTR` is either null or a pointer to a live, immovable |
| 1475 | // `Worker` |
no test coverage detected