From 63d54c6a625c09662e307e1938be57c59be38675 Mon Sep 17 00:00:00 2001 From: Hailey Somerville Date: Thu, 14 Sep 2023 13:45:57 +1000 Subject: [PATCH] AvailableTask::claim sets STATE_CLAIMED; STATE_SPAWNED set only after init --- embassy-executor/src/raw/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 0113510d..b47b90fb 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -199,12 +199,7 @@ impl AvailableTask { pub fn claim(task: &'static TaskStorage) -> Option { task.raw .state - .compare_exchange( - STATE_ELIGIBLE, - STATE_SPAWNED | STATE_RUN_QUEUED, - Ordering::AcqRel, - Ordering::Acquire, - ) + .compare_exchange(STATE_ELIGIBLE, STATE_CLAIMED, Ordering::AcqRel, Ordering::Acquire) .ok() .map(|_| Self { task }) } @@ -214,6 +209,11 @@ impl AvailableTask { self.task.raw.poll_fn.set(Some(TaskStorage::::poll)); 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); SpawnToken::new(task)