(&self, current_tick: u64)
| 1259 | pub(crate) membership: Membership, |
| 1260 | /// A sequence of jobs waiting to be executed. Newer jobs are executed |
| 1261 | /// before older ones, allowing efficient depth-first execution. During |
| 1262 | /// promotion, the oldest job is shared. Populated by `join()`. |
| 1263 | /// |
| 1264 | /// Jobs in this queue take precedence over those in the fifo queue. |
| 1265 | lifo_queue: JobQueue, |
| 1266 | /// A sequence of jobs waiting to be executed. Older jobs are executed |
| 1267 | /// before newer ones, providing reliably low latency. During promotion, |
| 1268 | /// this queue is partitioned into chunks and the chunks are shared. |
| 1269 | /// Populated by `spawn()`. |
| 1270 | /// |
| 1271 | /// Jobs in this queue are executed only when the lifo queue is empty. |
| 1272 | pub(crate) fifo_queue: JobQueue, |
| 1273 | /// A sequence of `!Sendf` jobs waitging to be executed. Older jobs are |
| 1274 | /// executed before newer ones. |
| 1275 | /// |
| 1276 | /// This queue does not participate in promotion. This is a `SeqQueue` so |
| 1277 | /// that a `Future` that is `!Send` and has been spawned onto this thread |
| 1278 | /// can be woken on another thread (the other thread then sends this thread |
| 1279 | /// a job that polls the future). |
| 1280 | pub(crate) nonsend_fifo_queue: Arc<SegQueue<JobRef>>, |
| 1281 | /// A local psudorandom number-generator. Used to spread out |
| 1282 | /// worker-to-worker operations evenly across the pool. |
| 1283 | rng: XorShift64Star, |
| 1284 | /// The CPU tick when work was last promoted from local to shared. This has |
| 1285 | /// no absolute relation to time. |
| 1286 | last_promote_tick: Cell<u64>, |
| 1287 | /// Set to true when executing a job that came from a different thread. |
| 1288 | migrated: Cell<bool>, |
| 1289 | // Make non-send. A `Worker` represents the local state of a particular |
| 1290 | // thread, so must be `!Send` and `!Sync`. It is already `!Sync` because of |
| 1291 | // `Cell`. |
| 1292 | _phantom: PhantomData<*const ()>, |
| 1293 | } |
| 1294 | |
| 1295 | use core::ops::Deref; |
| 1296 | |
| 1297 | impl Deref for Worker { |
| 1298 | type Target = Membership; |
| 1299 | |
| 1300 | fn deref(&self) -> &Membership { |
| 1301 | &self.membership |
| 1302 | } |
| 1303 | } |
| 1304 | |
| 1305 | /// Describes the outcome of a call to [`Worker::yield_now`] or |
| 1306 | /// [`Worker::yield_local`]. |
| 1307 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| 1308 | pub enum Yield { |
| 1309 | /// Indicates that a job was executed. |
| 1310 | Executed, |
| 1311 | /// Indicates that no job was executed. After receiving this, do not `yield` |
| 1312 | /// again until you have a reasonable expectation that new work will have |
| 1313 | /// been shared. |
| 1314 | Idle, |
| 1315 | } |
| 1316 | |
| 1317 | impl Worker { |
| 1318 | /// Calls the provided closure on the thread's worker instance, if it has |
no test coverage detected