status: cl_int,
cbs: [Vec<(EventCB, *mut c_void)>; 3],
fence: Option<PipeFence>,
+ work: Option<EventSig>,
}
#[repr(C)]
pub queue: Option<Arc<Queue>>,
pub cmd_type: cl_command_type,
pub deps: Vec<Arc<Event>>,
- work: Option<EventSig>,
state: Mutex<EventMutState>,
cv: Condvar,
}
status: CL_QUEUED as cl_int,
cbs: [Vec::new(), Vec::new(), Vec::new()],
fence: None,
+ work: Some(work),
}),
- work: Some(work),
cv: Condvar::new(),
})
}
status: CL_SUBMITTED as cl_int,
cbs: [Vec::new(), Vec::new(), Vec::new()],
fence: None,
+ work: None,
}),
- work: None,
cv: Condvar::new(),
})
}
let mut lock = self.state();
let status = lock.status;
if status == CL_QUEUED as cl_int {
- let new = self.work.as_ref().map_or(
+ let work = lock.work.take();
+ let new = work.as_ref().map_or(
// if there is no work
CL_SUBMITTED as cl_int,
|w| {
res
},
);
+ // we have to make sure that the work object is dropped before we notify about the
+ // status change. It's probably fine to move the value above, but we have to be
+ // absolutely sure it happens before the status update.
+ drop(work);
self.set_status(&mut lock, new);
new
} else {