]>
Commit | Line | Data |
---|---|---|
04155bda MT |
1 | #ifndef PARALLEL_CHECKOUT_H |
2 | #define PARALLEL_CHECKOUT_H | |
3 | ||
e9e8adf1 MT |
4 | #include "convert.h" |
5 | ||
04155bda MT |
6 | struct cache_entry; |
7 | struct checkout; | |
1c4d6f46 | 8 | struct progress; |
e9e8adf1 MT |
9 | |
10 | /**************************************************************** | |
11 | * Users of parallel checkout | |
12 | ****************************************************************/ | |
04155bda MT |
13 | |
14 | enum pc_status { | |
15 | PC_UNINITIALIZED = 0, | |
16 | PC_ACCEPTING_ENTRIES, | |
17 | PC_RUNNING, | |
18 | }; | |
19 | ||
20 | enum pc_status parallel_checkout_status(void); | |
7531e4b6 | 21 | void get_parallel_checkout_configs(int *num_workers, int *threshold); |
04155bda MT |
22 | |
23 | /* | |
24 | * Put parallel checkout into the PC_ACCEPTING_ENTRIES state. Should be used | |
25 | * only when in the PC_UNINITIALIZED state. | |
26 | */ | |
27 | void init_parallel_checkout(void); | |
28 | ||
29 | /* | |
30 | * Return -1 if parallel checkout is currently not accepting entries or if the | |
31 | * entry is not eligible for parallel checkout. Otherwise, enqueue the entry | |
32 | * for later write and return 0. | |
33 | */ | |
34 | int enqueue_checkout(struct cache_entry *ce, struct conv_attrs *ca); | |
1c4d6f46 | 35 | size_t pc_queue_size(void); |
04155bda | 36 | |
7531e4b6 MT |
37 | /* |
38 | * Write all the queued entries, returning 0 on success. If the number of | |
39 | * entries is smaller than the specified threshold, the operation is performed | |
40 | * sequentially. | |
41 | */ | |
1c4d6f46 MT |
42 | int run_parallel_checkout(struct checkout *state, int num_workers, int threshold, |
43 | struct progress *progress, unsigned int *progress_cnt); | |
04155bda | 44 | |
e9e8adf1 MT |
45 | /**************************************************************** |
46 | * Interface with checkout--worker | |
47 | ****************************************************************/ | |
48 | ||
49 | enum pc_item_status { | |
50 | PC_ITEM_PENDING = 0, | |
51 | PC_ITEM_WRITTEN, | |
52 | /* | |
53 | * The entry could not be written because there was another file | |
54 | * already present in its path or leading directories. Since | |
55 | * checkout_entry_ca() removes such files from the working tree before | |
56 | * enqueueing the entry for parallel checkout, it means that there was | |
57 | * a path collision among the entries being written. | |
58 | */ | |
59 | PC_ITEM_COLLIDED, | |
60 | PC_ITEM_FAILED, | |
61 | }; | |
62 | ||
63 | struct parallel_checkout_item { | |
64 | /* | |
65 | * In main process ce points to a istate->cache[] entry. Thus, it's not | |
66 | * owned by us. In workers they own the memory, which *must be* released. | |
67 | */ | |
68 | struct cache_entry *ce; | |
69 | struct conv_attrs ca; | |
70 | size_t id; /* position in parallel_checkout.items[] of main process */ | |
71 | ||
72 | /* Output fields, sent from workers. */ | |
73 | enum pc_item_status status; | |
74 | struct stat st; | |
75 | }; | |
76 | ||
77 | /* | |
78 | * The fixed-size portion of `struct parallel_checkout_item` that is sent to the | |
79 | * workers. Following this will be 2 strings: ca.working_tree_encoding and | |
80 | * ce.name; These are NOT null terminated, since we have the size in the fixed | |
81 | * portion. | |
82 | * | |
83 | * Note that not all fields of conv_attrs and cache_entry are passed, only the | |
84 | * ones that will be required by the workers to smudge and write the entry. | |
85 | */ | |
86 | struct pc_item_fixed_portion { | |
87 | size_t id; | |
88 | struct object_id oid; | |
89 | unsigned int ce_mode; | |
90 | enum convert_crlf_action crlf_action; | |
91 | int ident; | |
92 | size_t working_tree_encoding_len; | |
93 | size_t name_len; | |
94 | }; | |
95 | ||
96 | /* | |
97 | * The fields of `struct parallel_checkout_item` that are returned by the | |
98 | * workers. Note: `st` must be the last one, as it is omitted on error. | |
99 | */ | |
100 | struct pc_item_result { | |
101 | size_t id; | |
102 | enum pc_item_status status; | |
103 | struct stat st; | |
104 | }; | |
105 | ||
106 | #define PC_ITEM_RESULT_BASE_SIZE offsetof(struct pc_item_result, st) | |
107 | ||
108 | void write_pc_item(struct parallel_checkout_item *pc_item, | |
109 | struct checkout *state); | |
110 | ||
04155bda | 111 | #endif /* PARALLEL_CHECKOUT_H */ |