[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix thread-unsafe lazy initializations
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH] Fix thread-unsafe lazy initializations |
Date: |
Fri, 01 Mar 2013 10:23:30 +0100 |
User-agent: |
Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) |
Mark H Weaver <address@hidden> skribis:
> From dadcb1512569c1be039fc75f0a2967e370939e42 Mon Sep 17 00:00:00 2001
> From: Mark H Weaver <address@hidden>
> 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)
> address@hidden
> - 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)
> address@hidden
> + eval_string_var = scm_c_public_lookup ("ice-9 eval-string", "eval-string");
> address@hidden
>
> +SCM my_eval_string (SCM str)
> address@hidden
> 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’.
- Re: [PATCH] Fix thread-unsafe lazy initializations,
Ludovic Courtès <=