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

Method with_current

src/thread_pool.rs:1204–1228  ·  view source on GitHub ↗
(f: F)

Source from the content-addressed store, hash-verified

1202 /// Returns a reference to a worker's local inbox (where !Send future
1203 /// wakeups and broadcasts are transmitted).
1204 #[inline(always)]
1205 fn broadcast_queue(&self) -> &'static SegQueue<JobRef> {
1206 &self.member_data.broadcasts[self.member_index]
1207 }
1208
1209 /// Returns a reference to a worker's local inbox (where !Send future
1210 /// wakeups and broadcasts are transmitted).
1211 #[inline(always)]
1212 fn semaphore(&self) -> &'static Semaphore {
1213 &self.member_data.semaphores[self.member_index]
1214 }
1215
1216 /// Waits for a signal on this member's semaphore.
1217 fn wait(&self) {
1218 let semaphore = self.semaphore();
1219 semaphore
1220 .wait(1 << self.member_index, &self.thread_pool.waiting_bitmask);
1221 }
1222}
1223
1224impl Drop for Membership {
1225 fn drop(&mut self) {
1226 // Release the claim on this membership.
1227 self.thread_pool
1228 .claimed_bitmask
1229 .fetch_and(!(1 << self.member_index), Ordering::Release);
1230 // In case another thread is waiting for a membership slot to free
1231 // up, issue a wake on the bitmask.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected