
Martin Bonner wrote:
From: Tobias Schwinger
Johan Nilsson wrote:
Edson Tadeu wrote:
Does it support a single singleton across multiple DLL's? I.e., singleton S is accessed the first time by DLL A (and is created), then it is accessed by DLL B. Does DLL B create a new instance of singleton S for it, or can it use the one created by DLL A as a truly global singleton? Yes. See the documentation for details. Unless you have updated the documentation since the announcement, I
Tobias Schwinger wrote: think it would be a good idea to explain this in better detail. An 'implementation details' section would be a great addition to the document. OK, I'll take this as the "how does it work"-question :-).
It's actually quite easy: The macros introduce a member function that is defined in compiled code and used to access the Singleton. This way, all code to manage a Singleton's lifetime is in one place.
I haven't looked at the library, but I don't understand how that works on Windows. Won't both DLLs have their own copy of the compiled code, and hence won't they both have their own copy of the singleton?
No. Only one DLL has the code and the other one calls it. That is, given an appropriate .def file or 'declspec'ing of the class and correct usage of the placement macros. Regads, Tobias