AvailableTask::claim sets STATE_CLAIMED; STATE_SPAWNED set only after init
This commit is contained in:
parent
c4987b12a1
commit
63d54c6a62
@ -199,12 +199,7 @@ impl<F: Future + 'static> AvailableTask<F> {
|
|||||||
pub fn claim(task: &'static TaskStorage<F>) -> Option<Self> {
|
pub fn claim(task: &'static TaskStorage<F>) -> Option<Self> {
|
||||||
task.raw
|
task.raw
|
||||||
.state
|
.state
|
||||||
.compare_exchange(
|
.compare_exchange(STATE_ELIGIBLE, STATE_CLAIMED, Ordering::AcqRel, Ordering::Acquire)
|
||||||
STATE_ELIGIBLE,
|
|
||||||
STATE_SPAWNED | STATE_RUN_QUEUED,
|
|
||||||
Ordering::AcqRel,
|
|
||||||
Ordering::Acquire,
|
|
||||||
)
|
|
||||||
.ok()
|
.ok()
|
||||||
.map(|_| Self { task })
|
.map(|_| Self { task })
|
||||||
}
|
}
|
||||||
@ -214,6 +209,11 @@ impl<F: Future + 'static> AvailableTask<F> {
|
|||||||
self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll));
|
self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll));
|
||||||
self.task.future.write_in_place(future);
|
self.task.future.write_in_place(future);
|
||||||
|
|
||||||
|
self.task
|
||||||
|
.raw
|
||||||
|
.state
|
||||||
|
.store(STATE_SPAWNED | STATE_RUN_QUEUED, Ordering::Release);
|
||||||
|
|
||||||
let task = TaskRef::new(self.task);
|
let task = TaskRef::new(self.task);
|
||||||
|
|
||||||
SpawnToken::new(task)
|
SpawnToken::new(task)
|
||||||
|
Loading…
Reference in New Issue
Block a user