Hey,
I was trying to improve my project by trying to constrain JobHandleScoped to the life time of the JobScope type.
However, when I write the following piece of code:
let mut jobs = Vec::<_>::with_capacity(200);
{
let job_sys = JobSystem::new(2, 128).unwrap();
let js = JobScope::new_from_system(&job_sys);
let mut v: u32 = 0;
for _ in 0..100 {
let handle = js.create) || {}).unwrap();
js.run(&handle).unwrap();
jobs.push(handle);
}
}
}
I doesn't complain that the jobs Vec contains handles that will outlive the scope of the JobScope instance.
The handle is defined as:
pub struct ScopedJobHandle<'scope, T> {
h: usize,
p: PhantomData<T>
s: PhantomData<&'scope mut ()>,
}
and the function signature for create is
pub fn create<T>(&self, job: T) -> Result<ScopedJobHandle<T>, Error>
where
T: Sized + FnOnce() + Send
Am I missing something here? Are my lifetime annotations not sufficient?