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

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