1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use parking_lot::Mutex;

use crate::visitor::Visitor;

pub trait MarkingTask {
    fn execute(&mut self, visitor: &mut Visitor);
}

pub struct TaskScheduler(pub(crate) Mutex<Vec<Box<dyn MarkingTask>>>);
impl TaskScheduler {
    pub fn new() -> Self {
        Self(Mutex::new(vec![]))
    }
    pub fn add(&self, task: impl MarkingTask + 'static) {
        self.0.lock().push(Box::new(task));
    }
}