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

Method yield_local

src/thread_pool.rs:1462–1472  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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`

Callers 1

activateMethod · 0.80

Calls 2

find_local_workMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected