diff options
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 5a476213b..bdd5ff5ae 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -96,29 +96,6 @@ impl TaskRef { | |||
| 96 | &self.header().timer_queue_item | 96 | &self.header().timer_queue_item |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | /// Mark the task as timer-queued. Return whether it should be actually enqueued | ||
| 100 | /// using `_embassy_time_schedule_wake`. | ||
| 101 | /// | ||
| 102 | /// Entering this state prevents the task from being respawned while in a timer queue. | ||
| 103 | /// | ||
| 104 | /// Safety: | ||
| 105 | /// | ||
| 106 | /// This functions should only be called by the timer queue driver, before | ||
| 107 | /// enqueueing the timer item. | ||
| 108 | pub unsafe fn timer_enqueue(&self) -> timer_queue::TimerEnqueueOperation { | ||
| 109 | self.header().state.timer_enqueue() | ||
| 110 | } | ||
| 111 | |||
| 112 | /// Unmark the task as timer-queued. | ||
| 113 | /// | ||
| 114 | /// Safety: | ||
| 115 | /// | ||
| 116 | /// This functions should only be called by the timer queue implementation, after the task has | ||
| 117 | /// been removed from the timer queue. | ||
| 118 | pub unsafe fn timer_dequeue(&self) { | ||
| 119 | self.header().state.timer_dequeue() | ||
| 120 | } | ||
| 121 | |||
| 122 | /// The returned pointer is valid for the entire TaskStorage. | 99 | /// The returned pointer is valid for the entire TaskStorage. |
| 123 | pub(crate) fn as_ptr(self) -> *const TaskHeader { | 100 | pub(crate) fn as_ptr(self) -> *const TaskHeader { |
| 124 | self.ptr.as_ptr() | 101 | self.ptr.as_ptr() |
| @@ -195,25 +172,7 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 195 | match future.poll(&mut cx) { | 172 | match future.poll(&mut cx) { |
| 196 | Poll::Ready(_) => { | 173 | Poll::Ready(_) => { |
| 197 | this.future.drop_in_place(); | 174 | this.future.drop_in_place(); |
| 198 | |||
| 199 | // Mark this task to be timer queued. | ||
| 200 | // We're splitting the enqueue in two parts, so that we can change task state | ||
| 201 | // to something that prevent re-queueing. | ||
| 202 | let op = this.raw.state.timer_enqueue(); | ||
| 203 | |||
| 204 | // Now mark the task as not spawned, so that | ||
| 205 | // - it can be spawned again once it has been removed from the timer queue | ||
| 206 | // - it can not be timer-queued again | ||
| 207 | // We must do this before scheduling the wake, to prevent the task from being | ||
| 208 | // dequeued by the time driver while it's still SPAWNED. | ||
| 209 | this.raw.state.despawn(); | 175 | this.raw.state.despawn(); |
| 210 | |||
| 211 | // Now let's finish enqueueing. While we shouldn't get an `Ignore` here, it's | ||
| 212 | // better to be safe. | ||
| 213 | if op == timer_queue::TimerEnqueueOperation::Enqueue { | ||
| 214 | // Schedule the task in the past, so it gets dequeued ASAP. | ||
| 215 | unsafe { _embassy_time_schedule_wake(0, &waker) } | ||
| 216 | } | ||
| 217 | } | 176 | } |
| 218 | Poll::Pending => {} | 177 | Poll::Pending => {} |
| 219 | } | 178 | } |
| @@ -232,10 +191,6 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 232 | } | 191 | } |
| 233 | } | 192 | } |
| 234 | 193 | ||
| 235 | extern "Rust" { | ||
| 236 | fn _embassy_time_schedule_wake(at: u64, waker: &core::task::Waker); | ||
| 237 | } | ||
| 238 | |||
| 239 | /// An uninitialized [`TaskStorage`]. | 194 | /// An uninitialized [`TaskStorage`]. |
| 240 | pub struct AvailableTask<F: Future + 'static> { | 195 | pub struct AvailableTask<F: Future + 'static> { |
| 241 | task: &'static TaskStorage<F>, | 196 | task: &'static TaskStorage<F>, |
