1
use std::fmt::Debug;
2

            
3
use crate::tasks::handle::Id;
4
use crate::tasks::manager::Manager;
5
use crate::tasks::traits::Executable;
6
use crate::tasks::Job;
7

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

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

            
24
266989
        self.manager
25
266989
            .job_completed(self.id, self.key.as_ref(), result);
26
266989
    }
27
}