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
use super::*;
use crate::util::OpaquePointer;
pub trait Context: 'static + Send + Sync + Sized {
fn spawn_worker(worker: &'static Worker<Self>, _tls: OpaquePointer, context: &'static Self) {
let worker_ptr = worker as *const Worker<Self> as usize;
std::thread::spawn(move || {
let worker = unsafe { &mut *(worker_ptr as *mut Worker<Self>) };
worker.run(context);
});
}
}
impl Context for () {}
pub trait WorkerLocal {
fn init(&mut self, _tls: OpaquePointer) {}
}
impl WorkerLocal for () {}