unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: Andy Wingo <wingo@pobox.com>, guile-devel@gnu.org
Subject: Re: [PATCH] Fix thread-unsafe lazy initializations
Date: Fri, 01 Mar 2013 10:23:30 +0100	[thread overview]
Message-ID: <874ngv8odp.fsf@gnu.org> (raw)
In-Reply-To: <87fw0gvxdj.fsf_-_@tines.lan> (Mark H. Weaver's message of "Thu,  28 Feb 2013 18:20:40 -0500")

Mark H Weaver <mhw@netris.org> skribis:

> From dadcb1512569c1be039fc75f0a2967e370939e42 Mon Sep 17 00:00:00 2001
> From: Mark H Weaver <mhw@netris.org>
> Date: Thu, 28 Feb 2013 17:56:58 -0500
> Subject: [PATCH] Fix thread-unsafe lazy initializations.
>
> * libguile/debug.c (scm_local_eval):
>   libguile/ports.c (scm_current_warning_port):
>   libguile/strports.c (scm_eval_string_in_module): Perform
>   lazy-initialization while holding a mutex.  Use SCM_UNDEFINED as the
>   uninitialized value.  Use 'scm_c_*_variable'.
>
> * doc/ref/api-modules.texi (Accessing Modules from C): Fix
>   'my_eval_string' example to be thread-safe.

Looks good to me.

> --- 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, signals an error.  Returns a
>  variable, always.
>  
>  @example
> -SCM my_eval_string (SCM str)
> -@{
> -  static SCM eval_string_var = SCM_BOOL_F;
> +static SCM eval_string_var;
>  
> -  if (scm_is_false (eval_string_var))
> -    eval_string_var =
> -      scm_c_public_lookup ("ice-9 eval-string", "eval-string");
> +void my_init (void)
> +@{
> +  eval_string_var = scm_c_public_lookup ("ice-9 eval-string", "eval-string");
> +@}
>  
> +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 ‘my_init’, and perhaps mention
locking?

Ludo’.



  reply	other threads:[~2013-03-01  9:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-29 18:54 Thread-unsafe initialization problems in Guile Mark H Weaver
2012-11-29 20:05 ` Ludovic Courtès
2012-11-29 22:42   ` Mark H Weaver
2013-01-21 20:04     ` Andy Wingo
2013-01-23 17:50       ` Mark H Weaver
2013-01-23 18:25         ` Mark H Weaver
2013-02-28 21:07           ` Mark H Weaver
2013-02-28 23:20             ` [PATCH] Fix thread-unsafe lazy initializations Mark H Weaver
2013-03-01  9:23               ` Ludovic Courtès [this message]
2013-03-05 18:53                 ` Mark H Weaver
2013-03-05 20:45                   ` Ludovic Courtès
2013-03-05 21:10                     ` Mark H Weaver
2013-03-05 20:00             ` Thread-unsafe initialization problems in Guile Noah Lavine
2013-03-06  3:24               ` Mark H Weaver
2013-03-06  3:39                 ` Noah Lavine
2013-03-06  3:50                   ` Mark H Weaver
  -- strict thread matches above, loose matches on Subject: below --
2014-01-23 17:54 [PATCH] Fix thread-unsafe lazy initializations Mark H Weaver
2014-01-23 20:25 ` Panicz Maciej Godek
2014-01-23 21:22   ` Mark H Weaver
2014-01-23 22:20     ` Panicz Maciej Godek
2014-01-24  4:04       ` Mark H Weaver
2014-01-24 15:52 ` Mark H Weaver

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: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=874ngv8odp.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=mhw@netris.org \
    --cc=wingo@pobox.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.
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).