|
Boost : |
From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2008-03-02 09:33:27
Hi John,
> De: boost-bounces_at_[hidden] [boost-bounces_at_[hidden]] En nombre de John Maddock
> [john_at_[hidden]]
> Enviado el: domingo, 02 de marzo de 2008 14:12
> Para: Boost mailing list; rade_at_[hidden]
> Asunto: [boost] call_once, headers and shared libraries
>
> This came up in the floating point utilities review without a good answer,
> but it's a general problem that's in need of one, so let me try again....
>
> Suppose we have some global data that needs to be initialised, the obvious
> answer is to use boost::call_once to ensure that it gets initialised exactly
> once. But... what happens if this is used in a header to initialise some
> static variable inside a template instance, and that template is used in
> more than one shared library/dll? At least on Windows I'm assuming that
> each dll gets it's own instance of the template, and we end up with two
> different versions of the static data with unpleasant results. Other than
> "don't do that", does anyone have a design or usage pattern that sidesteps
> this issue?
Boost.Flyweight's intemodule_holder is designed to solve precisely this issue.
More info on this component at:
Component code:
http://svn.boost.org/svn/boost/sandbox/flyweight/boost/flyweight/intermodule_holder.hpp
svn.boost.org seems to be down at the moment. You can download a Boost.Flyweight
package from
http://www.boost-consulting.com/vault/index.php?&direction=0&order=&directory=Patterns
Best,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk