From c223fa379181210dd6fc399c0dc802259a8d9065 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 3 May 2022 16:08:48 +0200 Subject: [PATCH] Rename spawn_allocate to spawn_mark_used This commit contains a suggestion to rename TaskStorage::spawn_allocate. The motivation for this is when reading through the code I was expecting something else to happen in this method, due to 'allocate' in the method name. --- embassy/src/executor/raw/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/embassy/src/executor/raw/mod.rs b/embassy/src/executor/raw/mod.rs index 5cf399cdf..fb6a55611 100644 --- a/embassy/src/executor/raw/mod.rs +++ b/embassy/src/executor/raw/mod.rs @@ -164,14 +164,14 @@ impl TaskStorage { /// Once the task has finished running, you may spawn it again. It is allowed to spawn it /// on a different executor. pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken { - if self.spawn_allocate() { + if self.spawn_mark_used() { unsafe { SpawnToken::::new(self.spawn_initialize(future)) } } else { SpawnToken::::new_failed() } } - fn spawn_allocate(&'static self) -> bool { + fn spawn_mark_used(&'static self) -> bool { let state = STATE_SPAWNED | STATE_RUN_QUEUED; self.raw .state @@ -234,7 +234,7 @@ impl TaskPool { /// which will cause [`Spawner::spawn()`] to return the error. pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken { for task in &self.pool { - if task.spawn_allocate() { + if task.spawn_mark_used() { return unsafe { SpawnToken::::new(task.spawn_initialize(future)) }; } } @@ -282,7 +282,7 @@ impl TaskPool { // by the user, with arbitrary hand-implemented futures. This is why these return `SpawnToken`. for task in &self.pool { - if task.spawn_allocate() { + if task.spawn_mark_used() { return SpawnToken::::new(task.spawn_initialize(future)); } }