8000 kernel/collections/queue: rename `remove_first` to `remove_first_matching` by lschuermann · Pull Request #4033 · tock/tock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kernel/collections/queue: rename remove_first to remove_first_matching #4033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kernel/src/collections/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub trait Queue<T> {
fn dequeue(&mut self) -> Option<T>;

/// Remove and return one (the first) element that matches the predicate.
fn remove_first<F>(&mut self, f: F) -> Option<T>
fn remove_first_matching<F>(&mut self, f: F) -> Option<T>
where
F: Fn(&T) -> bool;

Expand Down
9 changes: 8 additions & 1 deletion kernel/src/collections/ring_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ impl<T: Copy> queue::Queue<T> for RingBuffer<'_, T> {
}
}

fn remove_first<F>(&mut self, f: F) -> Option<T>
/// Removes the first element for which the provided closure returns `true`.
///
/// This walks the ring buffer and, upon finding a matching element, removes
/// it. It then shifts all subsequent elements forward (filling the hole
/// created by removing the element).
///
/// If an element was removed, this function returns it as `Some(elem)`.
fn remove_first_matching<F>(&mut self, f: F) -> Option<T>
where
F: Fn(&T) -> bool,
{
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/process_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {

fn remove_upcall(&self, upcall_id: UpcallId) -> Option<Task> {
self.tasks.map_or(None, |tasks| {
tasks.remove_first(|task| match task {
tasks.remove_first_matching(|task| match task {
Task::FunctionCall(fc) => match fc.source {
FunctionCallSource::Driver(upid) => upid == upcall_id,
_ => false,
Expand Down
Loading
0