Skip to content

Commit

Permalink
move re-taking of tasks to try_recv
Browse files Browse the repository at this point in the history
  • Loading branch information
gterzian committed Apr 30, 2024
1 parent 451e7b6 commit eea3684
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/script/task_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {

/// Take a message from the front of the queue, without waiting if empty.
pub fn recv(&self) -> Result<T, ()> {
self.take_tasks(T::wake_up_msg());
self.msg_queue.borrow_mut().pop_front().ok_or(())
}

/// Same as recv.
/// Retry to take tasks, and then recv.
pub fn try_recv(&self) -> Result<T, ()> {
self.take_tasks(T::wake_up_msg());
self.recv()
}

Expand Down

0 comments on commit eea3684

Please sign in to comment.