Make wake_task
safe
This commit is contained in:
parent
48e1aab762
commit
b6ca6d699a
@ -444,14 +444,10 @@ impl Executor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wake a task by raw pointer.
|
/// Wake a task by `TaskRef`.
|
||||||
///
|
///
|
||||||
/// You can obtain task pointers from `Waker`s using [`task_from_waker`].
|
/// You can obtain a `TaskRef` from a `Waker` using [`task_from_waker`].
|
||||||
///
|
pub fn wake_task(task: TaskRef) {
|
||||||
/// # Safety
|
|
||||||
///
|
|
||||||
/// `task` must be a valid task pointer obtained from [`task_from_waker`].
|
|
||||||
pub unsafe fn wake_task(task: TaskRef) {
|
|
||||||
critical_section::with(|cs| {
|
critical_section::with(|cs| {
|
||||||
let header = task.header();
|
let header = task.header();
|
||||||
let state = header.state.load(Ordering::Relaxed);
|
let state = header.state.load(Ordering::Relaxed);
|
||||||
@ -465,8 +461,10 @@ pub unsafe fn wake_task(task: TaskRef) {
|
|||||||
header.state.store(state | STATE_RUN_QUEUED, Ordering::Relaxed);
|
header.state.store(state | STATE_RUN_QUEUED, Ordering::Relaxed);
|
||||||
|
|
||||||
// We have just marked the task as scheduled, so enqueue it.
|
// We have just marked the task as scheduled, so enqueue it.
|
||||||
let executor = &*header.executor.get();
|
unsafe {
|
||||||
executor.enqueue(cs, task);
|
let executor = &*header.executor.get();
|
||||||
|
executor.enqueue(cs, task);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user