Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche committed Jan 11, 2022
1 parent fbb40a6 commit 04230c9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 6 additions & 1 deletion tokio/src/runtime/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ impl<T> Local<T> {
}

/// Pushes a task to the back of the local queue, skipping the LIFO slot.
pub(super) fn push_back(&mut self, mut task: task::Notified<T>, inject: &Inject<T>, stats: &mut WorkerStatsBatcher) {
pub(super) fn push_back(
&mut self,
mut task: task::Notified<T>,
inject: &Inject<T>,
stats: &mut WorkerStatsBatcher,
) {
let tail = loop {
let head = self.inner.head.load(Acquire);
let (steal, real) = unpack(head);
Expand Down
3 changes: 1 addition & 2 deletions tokio/src/runtime/stats/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ impl RuntimeStats {
}

/// Increment the number of tasks scheduled externally
pub(crate) fn inc_remote_schedule_count(&self) {
}
pub(crate) fn inc_remote_schedule_count(&self) {}

pub(crate) fn worker(&self, _index: usize) -> &WorkerStats {
&WorkerStats {}
Expand Down
4 changes: 3 additions & 1 deletion tokio/src/runtime/stats/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ impl WorkerStatsBatcher {
.busy_duration_total
.store(self.busy_duration_total, Relaxed);

worker.local_schedule_count.store(self.local_schedule_count, Relaxed);
worker
.local_schedule_count
.store(self.local_schedule_count, Relaxed);
worker.overflow_count.store(self.overflow_count, Relaxed);
}

Expand Down
16 changes: 10 additions & 6 deletions tokio/src/runtime/thread_pool/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ impl Context {
} else {
// Not enough budget left to run the LIFO task, push it to
// the back of the queue and return.
core.run_queue.push_back(task, self.worker.inject(), &mut core.stats);
core.run_queue
.push_back(task, self.worker.inject(), &mut core.stats);
return Ok(core);
}
}
Expand Down Expand Up @@ -558,9 +559,10 @@ impl Core {

let target = &worker.shared.remotes[i];
let target_stats = worker.shared.stats.worker(i);
if let Some(task) = target
.steal
.steal_into(&mut self.run_queue, &mut self.stats, target_stats)
if let Some(task) =
target
.steal
.steal_into(&mut self.run_queue, &mut self.stats, target_stats)
{
return Some(task);
}
Expand Down Expand Up @@ -732,15 +734,17 @@ impl Shared {
// tasks to be executed. If **not** a yield, then there is more
// flexibility and the task may go to the front of the queue.
let should_notify = if is_yield {
core.run_queue.push_back(task, &self.inject, &mut core.stats);
core.run_queue
.push_back(task, &self.inject, &mut core.stats);
true
} else {
// Push to the LIFO slot
let prev = core.lifo_slot.take();
let ret = prev.is_some();

if let Some(prev) = prev {
core.run_queue.push_back(prev, &self.inject, &mut core.stats);
core.run_queue
.push_back(prev, &self.inject, &mut core.stats);
}

core.lifo_slot = Some(task);
Expand Down

0 comments on commit 04230c9

Please sign in to comment.