Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2007-08-25 08:22:01


----- 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. I don't see how
you're able to prevent this behavior for the local static data
of singleton_manager.

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