pub struct SharedState {
pub shutdown: Arc<AtomicBool>,
pub task_counter: Arc<AtomicU64>,
pub global_queue: Arc<Mutex<VecDeque<TaskId>>>,
pub results: Arc<Mutex<HashMap<TaskId, RtObject>>>,
}Expand description
Thread-safe shared state for the scheduler.
In a real multi-threaded implementation, this would be accessed by multiple worker threads.
Fields§
§shutdown: Arc<AtomicBool>Whether the scheduler should stop.
task_counter: Arc<AtomicU64>Global task counter.
global_queue: Arc<Mutex<VecDeque<TaskId>>>Shared global queue.
results: Arc<Mutex<HashMap<TaskId, RtObject>>>Shared task results.
Implementations§
Sourcepub fn request_shutdown(&self)
pub fn request_shutdown(&self)
Request shutdown.
Sourcepub fn should_shutdown(&self) -> bool
pub fn should_shutdown(&self) -> bool
Check if shutdown was requested.
Sourcepub fn next_task_id(&self) -> TaskId
pub fn next_task_id(&self) -> TaskId
Generate a new task ID.
Sourcepub fn store_result(&self, task_id: TaskId, result: RtObject)
pub fn store_result(&self, task_id: TaskId, result: RtObject)
Store a task result.
Sourcepub fn get_result(&self, task_id: TaskId) -> Option<RtObject>
pub fn get_result(&self, task_id: TaskId) -> Option<RtObject>
Get a task result.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more