From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Fix thread-unsafe lazy initializations Date: Tue, 05 Mar 2013 21:45:41 +0100 Message-ID: <87lia1h8y2.fsf@gnu.org> References: <87wqx4w878.fsf@tines.lan> <87vcco5g4j.fsf@gnu.org> <87mwy0vxog.fsf@tines.lan> <877gn62thq.fsf@pobox.com> <87txq7okkj.fsf@tines.lan> <87pq0voiym.fsf@tines.lan> <87mwuow3jx.fsf@tines.lan> <87fw0gvxdj.fsf_-_@tines.lan> <874ngv8odp.fsf@gnu.org> <87hakpel0z.fsf@tines.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1362517235 10347 80.91.229.3 (5 Mar 2013 21:00:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Mar 2013 21:00:35 +0000 (UTC) Cc: Andy Wingo , guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Mar 05 22:00:58 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UCyyo-0008SM-6o for guile-devel@m.gmane.org; Tue, 05 Mar 2013 22:00:58 +0100 Original-Received: from localhost ([::1]:46451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCyyS-0002px-JQ for guile-devel@m.gmane.org; Tue, 05 Mar 2013 16:00:36 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCyyK-0002o0-CE for guile-devel@gnu.org; Tue, 05 Mar 2013 16:00:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCyyJ-0001Lh-6c for guile-devel@gnu.org; Tue, 05 Mar 2013 16:00:28 -0500 Original-Received: from [2a01:e0b:1:123:ca0a:a9ff:fe03:271e] (port=60514 helo=xanadu.aquilenet.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCykC-0005RU-Pp for guile-devel@gnu.org; Tue, 05 Mar 2013 15:45:53 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id EC036CCF0; Tue, 5 Mar 2013 21:45:42 +0100 (CET) Original-Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ArGGs6TUfciG; Tue, 5 Mar 2013 21:45:42 +0100 (CET) Original-Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 4A185CA4B; Tue, 5 Mar 2013 21:45:42 +0100 (CET) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 15 =?utf-8?Q?Vent=C3=B4se?= an 221 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: <87hakpel0z.fsf@tines.lan> (Mark H. Weaver's message of "Tue, 05 Mar 2013 13:53:00 -0500") User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:e0b:1:123:ca0a:a9ff:fe03:271e X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15864 Archived-At: Mark H Weaver skribis: > ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Mark H Weaver skribis: >> >>> --- a/doc/ref/api-modules.texi >>> +++ b/doc/ref/api-modules.texi >>> @@ -942,14 +942,15 @@ the @var{name} is not bound in the module, signal= s an error. Returns a >>> variable, always. >>>=20=20 >>> @example >>> -SCM my_eval_string (SCM str) >>> -@{ >>> - static SCM eval_string_var =3D SCM_BOOL_F; >>> +static SCM eval_string_var; >>>=20=20 >>> - if (scm_is_false (eval_string_var)) >>> - eval_string_var =3D >>> - scm_c_public_lookup ("ice-9 eval-string", "eval-string"); >>> +void my_init (void) >>> +@{ >>> + eval_string_var =3D scm_c_public_lookup ("ice-9 eval-string", "eval-= string"); >>> +@} >>>=20=20 >>> +SCM my_eval_string (SCM str) >>> +@{ >>> return scm_call_1 (scm_variable_ref (eval_string_var), str); >>> @} >>> @end example >> >> The doc should say something about =E2=80=98my_init=E2=80=99, and perhap= s mention >> locking? > > Can you suggest some text? 'my_init' seems obvious to me, and given > that this is just an example for 'scm_c_*_lookup', it seems out of place > to talk about general locking issues here, but feel free to propose some > text to go here. Agreed. Perhaps just something like: =E2=80=9CNote that the program should ensure that =E2=80=98my_init=E2=80=99 is called only once, and in a thread-= safe way.=E2=80=9D Ludo=E2=80=99.