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
255640
    fn execute(&mut self) {
22
255640
        let result = self.job.execute();
23
255640

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