3
3
#include "entry.h"
4
4
#include "parallel-checkout.h"
5
5
#include "pkt-line.h"
6
+ #include "progress.h"
6
7
#include "run-command.h"
7
8
#include "sigchain.h"
8
9
#include "streaming.h"
@@ -17,6 +18,8 @@ struct parallel_checkout {
17
18
enum pc_status status ;
18
19
struct parallel_checkout_item * items ; /* The parallel checkout queue. */
19
20
size_t nr , alloc ;
21
+ struct progress * progress ;
22
+ unsigned int * progress_cnt ;
20
23
};
21
24
22
25
static struct parallel_checkout parallel_checkout ;
@@ -146,6 +149,20 @@ int enqueue_checkout(struct cache_entry *ce, struct conv_attrs *ca)
146
149
return 0 ;
147
150
}
148
151
152
+ size_t pc_queue_size (void )
153
+ {
154
+ return parallel_checkout .nr ;
155
+ }
156
+
157
+ static void advance_progress_meter (void )
158
+ {
159
+ if (parallel_checkout .progress ) {
160
+ (* parallel_checkout .progress_cnt )++ ;
161
+ display_progress (parallel_checkout .progress ,
162
+ * parallel_checkout .progress_cnt );
163
+ }
164
+ }
165
+
149
166
static int handle_results (struct checkout * state )
150
167
{
151
168
int ret = 0 ;
@@ -194,6 +211,7 @@ static int handle_results(struct checkout *state)
194
211
*/
195
212
ret |= checkout_entry_ca (pc_item -> ce , & pc_item -> ca ,
196
213
state , NULL , NULL );
214
+ advance_progress_meter ();
197
215
break ;
198
216
case PC_ITEM_PENDING :
199
217
have_pending = 1 ;
@@ -534,6 +552,9 @@ static void parse_and_save_result(const char *buffer, int len,
534
552
pc_item -> status = res -> status ;
535
553
if (st )
536
554
pc_item -> st = * st ;
555
+
556
+ if (res -> status != PC_ITEM_COLLIDED )
557
+ advance_progress_meter ();
537
558
}
538
559
539
560
static void gather_results_from_workers (struct pc_worker * workers ,
@@ -596,18 +617,25 @@ static void write_items_sequentially(struct checkout *state)
596
617
{
597
618
size_t i ;
598
619
599
- for (i = 0 ; i < parallel_checkout .nr ; i ++ )
600
- write_pc_item (& parallel_checkout .items [i ], state );
620
+ for (i = 0 ; i < parallel_checkout .nr ; i ++ ) {
621
+ struct parallel_checkout_item * pc_item = & parallel_checkout .items [i ];
622
+ write_pc_item (pc_item , state );
623
+ if (pc_item -> status != PC_ITEM_COLLIDED )
624
+ advance_progress_meter ();
625
+ }
601
626
}
602
627
603
- int run_parallel_checkout (struct checkout * state , int num_workers , int threshold )
628
+ int run_parallel_checkout (struct checkout * state , int num_workers , int threshold ,
629
+ struct progress * progress , unsigned int * progress_cnt )
604
630
{
605
631
int ret ;
606
632
607
633
if (parallel_checkout .status != PC_ACCEPTING_ENTRIES )
608
634
BUG ("cannot run parallel checkout: uninitialized or already running" );
609
635
610
636
parallel_checkout .status = PC_RUNNING ;
637
+ parallel_checkout .progress = progress ;
638
+ parallel_checkout .progress_cnt = progress_cnt ;
611
639
612
640
if (parallel_checkout .nr < num_workers )
613
641
num_workers = parallel_checkout .nr ;
0 commit comments