History

And another one down

Sebastian Thiel committed 5 years ago

Commit abce75e1 parent 7f9be362 files · +12 −4Browse files

Unified · Split

2 files
  1. git-pack/src/index/traverse/reduce.rs +9 −3
  2. git-pack/src/index/traverse/with_lookup.rs +3 −1
git-pack/src/index/traverse/reduce.rs+9−3
@@ -1,6 +1,9 @@
11 use crate::{data, index::traverse};
2−use git_features::{interrupt::is_triggered, parallel, progress::Progress};
3−use std::time::Instant;
2+use git_features::{parallel, progress::Progress};
3+use std::{
4+ sync::atomic::{AtomicBool, Ordering},
5+ time::Instant,
6+};
47
58 fn add_decode_result(lhs: &mut data::decode_entry::Outcome, rhs: data::decode_entry::Outcome) {
69 lhs.num_deltas += rhs.num_deltas;
@@ -24,6 +27,7 @@ pub struct Reducer<'a, P, E> { · 17 unmodified lines
2427 then: Instant,
2528 entries_seen: usize,
2629 stats: traverse::Outcome,
30+ should_interrupt: &'a AtomicBool,
2731 _error: std::marker::PhantomData<E>,
2832 }
2933
@@ -35,6 +39,7 @@ where · 5 unmodified lines
3539 progress: &'a parking_lot::Mutex<P>,
3640 pack_data_len_in_bytes: usize,
3741 check: traverse::SafetyCheck,
42+ should_interrupt: &'a AtomicBool,
3843 ) -> Self {
3944 let stats = traverse::Outcome {
4045 pack_size: pack_data_len_in_bytes as u64,
@@ -45,6 +50,7 @@ where · 4 unmodified lines
4550 check,
4651 then: Instant::now(),
4752 entries_seen: 0,
53+ should_interrupt,
4854 stats,
4955 _error: Default::default(),
5056 }
@@ -93,7 +99,7 @@ where · 42 unmodified lines
9399 add_decode_result(&mut self.stats.average, chunk_total);
94100 self.progress.lock().set(self.entries_seen);
95101
96− if is_triggered() {
102+ if self.should_interrupt.load(Ordering::SeqCst) {
97103 return Err(Self::Error::Interrupted);
98104 }
99105 Ok(())
git-pack/src/index/traverse/with_lookup.rs+3−1
@@ -5,6 +5,7 @@ use git_features::{ · 4 unmodified lines
55 parallel::{self, in_parallel_if},
66 progress::{self, unit, Progress},
77 };
8+use std::sync::Arc;
89
910 mod options {
1011 use crate::index::traverse::SafetyCheck;
@@ -69,6 +70,7 @@ impl index::File { · 58 unmodified lines
6970 {
7071 let pack_progress = progress.add_child("SHA1 of pack");
7172 let index_progress = progress.add_child("SHA1 of index");
73+ let should_interrupt = Arc::clone(&should_interrupt);
7274 move || {
7375 let res = self.possibly_verify(pack, check, pack_progress, index_progress, should_interrupt);
7476 if res.is_err() {
@@ -139,7 +141,7 @@ impl index::File { · 64 unmodified lines
139141 }
140142 Ok(stats)
141143 },
142− Reducer::from_progress(&reduce_progress, pack.data_len(), check),
144+ Reducer::from_progress(&reduce_progress, pack.data_len(), check, &should_interrupt),
143145 )
144146 },
145147 );

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t