MCPcopy Create free account
hub / github.com/git/git / start_threads

Function start_threads

builtin/grep.c:227–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227static void start_threads(struct grep_opt *opt)
228{
229 int i;
230
231 pthread_mutex_init(&grep_mutex, NULL);
232 pthread_mutex_init(&grep_attr_mutex, NULL);
233 pthread_cond_init(&cond_add, NULL);
234 pthread_cond_init(&cond_write, NULL);
235 pthread_cond_init(&cond_result, NULL);
236 grep_use_locks = 1;
237 enable_obj_read_lock();
238
239 for (i = 0; i < ARRAY_SIZE(todo); i++) {
240 strbuf_init(&todo[i].out, 0);
241 }
242
243 CALLOC_ARRAY(threads, num_threads);
244 for (i = 0; i < num_threads; i++) {
245 int err;
246 struct grep_opt *o = grep_opt_dup(opt);
247 o->output = strbuf_out;
248 compile_grep_patterns(o);
249 err = pthread_create(&threads[i], NULL, run, o);
250
251 if (err)
252 die(_("grep: failed to create thread: %s"),
253 strerror(err));
254 }
255}
256
257static int wait_all(void)
258{

Callers 1

cmd_grepFunction · 0.85

Calls 6

enable_obj_read_lockFunction · 0.85
strbuf_initFunction · 0.85
grep_opt_dupFunction · 0.85
compile_grep_patternsFunction · 0.85
pthread_createFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected