1- use std:: sync:: { atomic:: AtomicBool , Arc } ;
1+ use std:: sync:: atomic:: AtomicBool ;
22
33use git_features:: {
44 parallel,
@@ -21,13 +21,13 @@ mod types;
2121pub use types:: { Algorithm , Outcome , SafetyCheck } ;
2222
2323mod options {
24- use std:: sync:: { atomic:: AtomicBool , Arc } ;
24+ use std:: sync:: atomic:: AtomicBool ;
2525
2626 use crate :: index:: traverse:: { Algorithm , SafetyCheck } ;
2727
2828 /// Traversal options for [`traverse()`][crate::index::File::traverse()]
2929 #[ derive( Debug , Clone ) ]
30- pub struct Options {
30+ pub struct Options < ' a > {
3131 /// The algorithm to employ.
3232 pub algorithm : Algorithm ,
3333 /// If `Some`, only use the given amount of threads. Otherwise, the amount of threads to use will be selected based on
@@ -37,18 +37,7 @@ mod options {
3737 pub check : SafetyCheck ,
3838 /// A flag to indicate whether the algorithm should be interrupted. Will be checked occasionally allow stopping a running
3939 /// computation.
40- pub should_interrupt : Arc < AtomicBool > ,
41- }
42-
43- impl Default for Options {
44- fn default ( ) -> Self {
45- Self {
46- algorithm : Algorithm :: Lookup ,
47- thread_limit : Default :: default ( ) ,
48- check : Default :: default ( ) ,
49- should_interrupt : Default :: default ( ) ,
50- }
51- }
40+ pub should_interrupt : & ' a AtomicBool ,
5241 }
5342}
5443pub use options:: Options ;
@@ -86,7 +75,7 @@ impl index::File {
8675 thread_limit,
8776 check,
8877 should_interrupt,
89- } : Options ,
78+ } : Options < ' _ > ,
9079 ) -> Result < ( git_hash:: ObjectId , Outcome , Option < P > ) , Error < E > >
9180 where
9281 P : Progress ,
@@ -125,7 +114,7 @@ impl index::File {
125114 check : SafetyCheck ,
126115 pack_progress : impl Progress ,
127116 index_progress : impl Progress ,
128- should_interrupt : Arc < AtomicBool > ,
117+ should_interrupt : & AtomicBool ,
129118 ) -> Result < git_hash:: ObjectId , Error < E > >
130119 where
131120 E : std:: error:: Error + Send + Sync + ' static ,
@@ -138,11 +127,8 @@ impl index::File {
138127 } ) ;
139128 }
140129 let ( pack_res, id) = parallel:: join (
141- {
142- let should_interrupt = Arc :: clone ( & should_interrupt) ;
143- move || pack. verify_checksum ( pack_progress, & should_interrupt)
144- } ,
145- move || self . verify_checksum ( index_progress, & should_interrupt) ,
130+ move || pack. verify_checksum ( pack_progress, should_interrupt) ,
131+ move || self . verify_checksum ( index_progress, should_interrupt) ,
146132 ) ;
147133 pack_res?;
148134 id?
0 commit comments