aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-05-03 14:58:24 +0000
committerGitHub <[email protected]>2022-05-03 14:58:24 +0000
commit85c0525e01c52bbb85c7b93600a60837ee7b87dc (patch)
treecf7812c754705fe59e57e12caecb286a4548c73b
parent49ae26f3846930e6a89cc10d176fbd0403b4d0c2 (diff)
parentc223fa379181210dd6fc399c0dc802259a8d9065 (diff)
Merge #749
749: Rename spawn_allocate to spawn_mark_used r=Dirbaio a=danbev 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. I'm very new to this code base so I may be wrong in thinking this is a good change, but I wanted to open this PR to get some feedback. Co-authored-by: Daniel Bevenius <[email protected]>
-rw-r--r--embassy/src/executor/raw/mod.rs8
1 files 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<F: Future + 'static> TaskStorage<F> {
164 /// Once the task has finished running, you may spawn it again. It is allowed to spawn it 164 /// Once the task has finished running, you may spawn it again. It is allowed to spawn it
165 /// on a different executor. 165 /// on a different executor.
166 pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken<impl Sized> { 166 pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken<impl Sized> {
167 if self.spawn_allocate() { 167 if self.spawn_mark_used() {
168 unsafe { SpawnToken::<F>::new(self.spawn_initialize(future)) } 168 unsafe { SpawnToken::<F>::new(self.spawn_initialize(future)) }
169 } else { 169 } else {
170 SpawnToken::<F>::new_failed() 170 SpawnToken::<F>::new_failed()
171 } 171 }
172 } 172 }
173 173
174 fn spawn_allocate(&'static self) -> bool { 174 fn spawn_mark_used(&'static self) -> bool {
175 let state = STATE_SPAWNED | STATE_RUN_QUEUED; 175 let state = STATE_SPAWNED | STATE_RUN_QUEUED;
176 self.raw 176 self.raw
177 .state 177 .state
@@ -234,7 +234,7 @@ impl<F: Future + 'static, const N: usize> TaskPool<F, N> {
234 /// which will cause [`Spawner::spawn()`] to return the error. 234 /// which will cause [`Spawner::spawn()`] to return the error.
235 pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken<impl Sized> { 235 pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken<impl Sized> {
236 for task in &self.pool { 236 for task in &self.pool {
237 if task.spawn_allocate() { 237 if task.spawn_mark_used() {
238 return unsafe { SpawnToken::<F>::new(task.spawn_initialize(future)) }; 238 return unsafe { SpawnToken::<F>::new(task.spawn_initialize(future)) };
239 } 239 }
240 } 240 }
@@ -282,7 +282,7 @@ impl<F: Future + 'static, const N: usize> TaskPool<F, N> {
282 // by the user, with arbitrary hand-implemented futures. This is why these return `SpawnToken<F>`. 282 // by the user, with arbitrary hand-implemented futures. This is why these return `SpawnToken<F>`.
283 283
284 for task in &self.pool { 284 for task in &self.pool {
285 if task.spawn_allocate() { 285 if task.spawn_mark_used() {
286 return SpawnToken::<FutFn>::new(task.spawn_initialize(future)); 286 return SpawnToken::<FutFn>::new(task.spawn_initialize(future));
287 } 287 }
288 } 288 }