|
1 | 1 | use super::stat::SchedulerStat; |
2 | 2 | use super::work_bucket::*; |
3 | | -use super::worker::{GCWorker, WorkerGroup}; |
| 3 | +use super::worker::{GCWorker, StealerWithOrdinal, WorkerGroup}; |
4 | 4 | use super::*; |
5 | 5 | use crate::mmtk::MMTK; |
6 | 6 | use crate::util::opaque_pointer::*; |
@@ -119,13 +119,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> { |
119 | 119 | { |
120 | 120 | // Unconstrained is always open. Prepare will be opened at the beginning of a GC. |
121 | 121 | // This vec will grow for each stage we call with open_next() |
122 | | - let first_stw_stage = self |
123 | | - .work_buckets |
124 | | - .iter() |
125 | | - .skip(1) |
126 | | - .next() |
127 | | - .map(|(id, _)| id) |
128 | | - .unwrap(); |
| 122 | + let first_stw_stage = self.work_buckets.iter().nth(1).map(|(id, _)| id).unwrap(); |
129 | 123 | let mut open_stages: Vec<WorkBucketStage> = vec![first_stw_stage]; |
130 | 124 | // The rest will open after the previous stage is done. |
131 | 125 | let mut open_next = |s: WorkBucketStage| { |
@@ -320,13 +314,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> { |
320 | 314 | } |
321 | 315 |
|
322 | 316 | pub fn reset_state(&self) { |
323 | | - let first_stw_stage = self |
324 | | - .work_buckets |
325 | | - .iter() |
326 | | - .skip(1) |
327 | | - .next() |
328 | | - .map(|(id, _)| id) |
329 | | - .unwrap(); |
| 317 | + let first_stw_stage = self.work_buckets.iter().nth(1).map(|(id, _)| id).unwrap(); |
330 | 318 | self.work_buckets.iter().for_each(|(id, bkt)| { |
331 | 319 | if id != WorkBucketStage::Unconstrained && id != first_stw_stage { |
332 | 320 | bkt.deactivate(); |
@@ -366,7 +354,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> { |
366 | 354 | _ => {} |
367 | 355 | } |
368 | 356 | } |
369 | | - for (id, stealer) in &self.worker_group().stealers { |
| 357 | + for StealerWithOrdinal { id, stealer } in &self.worker_group().stealers { |
370 | 358 | if *id == worker.ordinal { |
371 | 359 | continue; |
372 | 360 | } |
@@ -463,7 +451,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> { |
463 | 451 |
|
464 | 452 | pub fn notify_mutators_paused(&self, mmtk: &'static MMTK<VM>) { |
465 | 453 | mmtk.plan.base().control_collector_context.clear_request(); |
466 | | - let first_stw_bucket = self.work_buckets.values().skip(1).next().unwrap(); |
| 454 | + let first_stw_bucket = self.work_buckets.values().nth(1).unwrap(); |
467 | 455 | debug_assert!(!first_stw_bucket.is_activated()); |
468 | 456 | first_stw_bucket.activate(); |
469 | 457 | let _guard = self.worker_monitor.0.lock().unwrap(); |
|
0 commit comments