1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use super::job::*;
use std::mem;
pub struct UnsafeJob {
action: *const dyn ScheduledJob
}
impl UnsafeJob {
pub fn new<'a>(action: &'a dyn ScheduledJob) -> UnsafeJob {
let action_ptr: *const dyn ScheduledJob = action;
unsafe { UnsafeJob { action: mem::transmute(action_ptr) } }
}
}
unsafe impl Send for UnsafeJob {}
impl ScheduledJob for UnsafeJob {
fn run(&mut self) {
unsafe {
let action = self.action as *mut dyn ScheduledJob;
(*action).run();
}
}
}