git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: "git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: What's cooking in git.git (Sep 2016, #08; Tue, 27)
Date: Mon, 03 Oct 2016 13:49:53 -0700	[thread overview]
Message-ID: <xmqqwphp5f9q.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CAGZ79ka8dO1AHJftKAqD6LvxJSP+8yGGa7Citcdxxrnc5DMeYg@mail.gmail.com> (Stefan Beller's message of "Mon, 3 Oct 2016 12:55:55 -0700")

Stefan Beller <sbeller@google.com> writes:

> I am looking at the tip of jc/attr-more and for a minimum
> thread safety we'd want to change the call sites to be aware of the
> threads, i.e. instead of doing
>
      static struct git_attr_check *check;	
>     if (!check)
>         check = git_attr_check_initl("crlf", "ident",
>                     "filter", "eol", "text",
>                     NULL);
>
> We'd rather call
>
>         struct git_attr_check *check;
>         check = git_attr_check_lookup_or_initl_threadsafe(
>                 "crlf", "ident", "filter", "eol", "text", NULL);
>          if (!git_check_attr(path, check)) {
>              ...

I actually am hoping that the "static" can be kept so that we can
minimize the cost of interning these symbols into struct git_attr.

The initialization would thus become something like:

	static struct git_attr_check *check;
	git_attr_check_initl(&check, "crlf", "ident", ..., NULL);

The structure will have an array of git_attr[], once interned will
be shared and used by everybody.  _initl() will need to make sure
that the "check" pointer is updated atomically so that multiple
people racing to initialize this variable will not step on each
others' toes.

Then the use site would do something like

	const char *result[... some size ...];
	git_check_attr(path, check, result[]);

to receive result regardless of anybody else who is using the same
"check" structure to ask the same question (for different paths).

  parent reply	other threads:[~2016-10-03 20:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-27 23:23 What's cooking in git.git (Sep 2016, #08; Tue, 27) Junio C Hamano
2016-10-01  1:33 ` Stefan Beller
2016-10-03 18:07   ` Junio C Hamano
2016-10-03 19:55     ` Stefan Beller
2016-10-03 20:17       ` Junio C Hamano
2016-10-03 20:49       ` Junio C Hamano [this message]
2016-10-03 21:49         ` Stefan Beller
2016-10-03 21:56           ` Junio C Hamano
2016-10-03 22:17             ` Stefan Beller
2016-10-04 16:11               ` Junio C Hamano
2016-10-04 22:36                 ` Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwphp5f9q.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).