Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-05-06 16:18:05


Pavel Antokolsky aka Zigmar wrote:

>On 5/6/05, Pavel Vozenilek <pavel_vozenilek_at_[hidden]> wrote:
>
>
>>Win32 DLLs would need some support - Windows does not resolve
>>statics when a DLL is loaded.
>>
>>Either explicit registering of Singleton infrastructure from each DLL
>>would be needed or perhaps using shared segment.
>>
>>
>
>AFAIK there is no platform independent way to deal with shared memory,
>if that what you mean.
>Regarding the problem, I was thinking of some kind of way to specify
>the storage type manually.
>
>For example something like in this fictional example:
>--- my_singleton.h
>class my_singleton : public boost::singleton_ex< my_singleton,
>static_lifetime, manual_storage >
>{
> //...
>};
>--- my_singleton.cpp
>my_singleton::storage_type storage;
>
>I'm not proposing such interface, but the idea is to allow to used to
>leave the storage object inside the Singleton uninitialized, and allow
>him to create it manually where he wants to (i.e. in shared memory or
>inside implementation file).
>
>
Actually, something like this already exists.

class MySingleton :
    public singleton_ex
    <
        MySingleton,
        lifo_lifetime_ex
        <
            default_creation,
            create_using_std_allocator_ex
            <
                false, // throw if memory can't be allocated
                some_shared_memory_allocator < MySingleton >
>
>
>
{
};

You would have to provide some_shared_memory_allocator, which would take
the form of a standard allocator policy.

-Jason


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