asynchronix/executor/
worker.rs

1use std::cell::Cell;
2use std::sync::Arc;
3
4use super::task::Runnable;
5
6use super::ExecutorContext;
7use super::LocalQueue;
8
9/// A local worker with access to global executor resources.
10pub(crate) struct Worker {
11    pub(super) local_queue: LocalQueue,
12    pub(super) fast_slot: Cell<Option<Runnable>>,
13    pub(super) executor_context: Arc<ExecutorContext>,
14}
15
16impl Worker {
17    /// Creates a new worker.
18    pub(super) fn new(local_queue: LocalQueue, executor_context: Arc<ExecutorContext>) -> Self {
19        Self {
20            local_queue,
21            fast_slot: Cell::new(None),
22            executor_context,
23        }
24    }
25}