Skip to content

Commit

Permalink
Clang 15, improve a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpdemarco committed Nov 30, 2023
1 parent 4f5362e commit 19505c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"os": "ubuntu-22.04"
},
{
"name": "Linux Clang 14",
"name": "Linux Clang 15",
"compiler": "clang",
"version": "14",
"version": "15",
"os": "ubuntu-22.04"
},
{
Expand Down
6 changes: 4 additions & 2 deletions rustport/src/stlab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,23 @@ impl PriorityTaskSystem {
self.execute_task(Box::new(f), p)
}

/// Push `task` to the first queue in `queues` whose mutex is not under contention.
/// If no such queue is found after a single pass, blockingly push `task` to one queue.
pub fn execute_task(&self, task: Task, priority: Priority) {
self.pool.execute_immediately(|queues| {
let mut task: Option<Task> = Some(task);
let i = self.index.fetch_add(1, MemoryOrdering::SeqCst);
let n = self.available_parallelism;

// Attempt to push to a queue without blocking, starting with ours.
// Attempt to push to each queue without blocking.
for i in (i..i + n).map(|i| i % n) {
task = queues.get(i).unwrap().try_push(task.unwrap(), priority);
if task.is_none() {
return;
} // An empty return means push was successful.
}

// Otherwise, attempt to push to our queue, with blocking.
// Otherwise, attempt to blockingly push to one queue.
queues.get(i % n).unwrap().push(task.unwrap(), priority);
});
}
Expand Down

0 comments on commit 19505c6

Please sign in to comment.