Re: [RFC][PATCH] grep: enable threading for context line printing
From: Fredrik Kuivinen <hidden>
Date: 2016-06-15 22:48:25
On Sun, Mar 14, 2010 at 19:18, René Scharfe [off-list ref] wrote:
This patch makes work_done() in builtin/grep.c print hunk marks between files if threading is used, while show_line() in grep.c still does the same in the other case. The latter is controlled by the struct grep_opt member show_hunk_mark: 0 means show_line() prints no hunk marks between files, 1 means it prints them before the next file with matches and 2 means it prints them before matches from the current file. Having two places for this is a bit ugly but it enables parallel grep for the common -ABC options. Locking should be fine in add_work(). Comments?
The implementation looks correct. As you say it is a bit ugly, but I think it is worth it anyway. (The solutions I managed to come up with when I wrote the original threaded grep patch were even uglier, that is why I simply disabled the threading in that case.) Symbolic constants for the magic values 0, 1, and 2 would make the code more readable. - Fredrik