]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/grep.c
grep: clean up num_threads handling
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 3 Nov 2018 08:48:44 +0000 (09:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Nov 2018 04:42:11 +0000 (13:42 +0900)
commitfd6263fb733e50cfbcf857136388bf47d9c5151f
tree3a99ad14b7c732af1035e08da8c17cbd0715d4b0
parent4002e87cb254298fa2f44b98ee1b618bda0e8b59
grep: clean up num_threads handling

When NO_PTHREADS is still used in this file, we have two separate code
paths for thread and no thread support. The latter will always have
num_threads remain zero while the former uses num_threads zero as
"default number of threads".

With recent changes blur the line between thread and no-thread
support, this num_threads handling becomes a bit strange so let's
redefine it like this:

- num_threads == 0 means default number of threads and should become
  positive after all configuration and option parsing is done if
  multithread is supported.

- num_threads <= 1 runs no threads. It does not matter if the platform
  supports threading or not.

- num_threads > 1 will run multiple threads and is invalid if
  HAVE_THREADS is false. pthread API is only used in this case.

PS. a new warning is also added when num_threads is forced back to one
because a thread-incompatible option is specified.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c