git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 2/3] grep: enable threading with -p and -W using lazy attribute lookup

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Dec 16, 2011, 08:22 UTC
Message-ID
<4EEAFFAF.8030003@viscovery.net>
In-Reply-To
<138b930c0c96029f2fb9a816e73e70a4d5bce1de.1323723759.git.trast@student.ethz.ch>
Am 12/12/2011 22:16, schrieb Thomas Rast:
Show 23 quoted lines
> diff --git a/grep.h b/grep.h
> index a652800..15d227c 100644
> --- a/grep.h
> +++ b/grep.h
> @@ -115,6 +115,7 @@ struct grep_opt {
>  	int show_hunk_mark;
>  	int file_break;
>  	int heading;
> +	int use_threads;
>  	void *priv;
>  
>  	void (*output)(struct grep_opt *opt, const void *data, size_t size);
> @@ -131,4 +132,10 @@ struct grep_opt {
>  extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
>  extern int grep_threads_ok(const struct grep_opt *opt);
>  
> +#ifndef NO_PTHREADS
> +/* Mutex used around access to the attributes machinery if
> + * opt->use_threads.  Must be initialized/destroyed by callers! */
> +extern pthread_mutex_t grep_attr_mutex;
> +#endif
> +
>  #endif

This is the first time we use pthread_mutex_t in a header file. We need at least the following squashed in. An alternative would be to include "thread-utils.h", but thread-utils is really more about implementation helpers functions, not about types, and therefore does not look right to be #included in a header.

---
 grep.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/grep.h b/grep.h
index 15d227c..754b270 100644
--- a/grep.h
+++ b/grep.h
@@ -133,6 +133,7 @@ extern struct grep_opt *grep_opt_dup(const struct
grep_opt *opt);
 extern int grep_threads_ok(const struct grep_opt *opt);

 #ifndef NO_PTHREADS
+#include <pthread.h>
 /* Mutex used around access to the attributes machinery if
  * opt->use_threads.  Must be initialized/destroyed by callers! */
 extern pthread_mutex_t grep_attr_mutex;
-- 
1.7.8.1436.gb3021
Previous: Thomas RastNext: Junio C Hamano
Message 4 of 9 in “grep attributes and multithreading”
  1. 0/3 grep attributes and multithreadingThomas Rast, Dec 12, 2011
  2. 1/3 grep: load funcname patterns for -WThomas Rast, Dec 12, 2011
  3. 2/3 grep: enable threading with -p and -W using lazy attribute lookupThomas Rast, Dec 12, 2011
  4. Johannes SixtDec 16, 2011
  5. Junio C HamanoDec 16, 2011
  6. 3/3 grep: disable threading in non-worktree caseThomas Rast, Dec 12, 2011
  7. René ScharfeDec 12, 2011
  8. Junio C HamanoDec 12, 2011
  9. Thomas RastDec 13, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.