1
use std::fmt::Debug;
2

            
3
use crate::tasks::{handle::Id, manager::Manager, traits::Executable, Job};
4

            
5
#[derive(Debug)]
6
pub struct ManagedJob<J, Key> {
7
    pub id: Id,
8
    pub job: J,
9
    pub manager: Manager<Key>,
10
    pub key: Option<Key>,
11
}
12

            
13
impl<J, Key> Executable for ManagedJob<J, Key>
14
where
15
    J: Job,
16
    Key: Clone + std::hash::Hash + Eq + Send + Sync + Debug + 'static,
17
{
18
188303
    fn execute(&mut self) {
19
188303
        let result = self.job.execute();
20
188303

            
21
188303
        self.manager
22
188303
            .job_completed(self.id, self.key.as_ref(), result);
23
188303
    }
24
}