Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-08-25 15:01:20


JOAQUIN LOPEZ MU?Z wrote:
> ----- Mensaje original -----
> De: Tobias Schwinger <tschwinger_at_[hidden]>
> Fecha: Sábado, Agosto 25, 2007 1:06 am
> Asunto: Re: [boost] Threadsafe singleton - questions
> Para: boost_at_[hidden]
>
>> Robert Ramey wrote:
> [...]
>>> g) what happens if same interface used by different DLLS.
>>> Is one instance still created?
>> Yes.
>
> Are you sure? For instance, in Windows globals aren't merged
> on DLL loading, so if you've got something like:
>
> /*** foo.hpp ***/
> template<typename T>
> struct foo
> {
> static T* get()
> {
> T t;
> return &t;
> }
> };
>
> /*** main.cpp ***/
> #include "foo.hpp"
>
> T* t1=foo<T>::get();
>
> /*** dll1.cpp ***/
> #include "foo.hpp"
>
> T* t2=foo<T>::get();
>
> you'll get different t1 and t2 values.

Right.

> I don't see how
> you're able to prevent this behavior for the local static data
> of singleton_manager.

Not at all: As client Singletons are user classes it's the users
responsibility to eventually add declspec stuff for windows.

It should probably be mentioned in the docs. Thanks for the heads up.

Regards,
Tobias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk