Subject: Re: [boost] Solving Robert's singleton problem
From: Bjorn Reese (breese_at_[hidden])
Date: 2018-10-20 18:33:07
On 10/18/18 10:19 PM, Niall Douglas via Boost wrote:
> The way I have solved this problem is brutal, but it works. In my
> singleton constructor, I create a named shared memory area unique to my
> process. In that named shared memory area, I store a pointer to myself,
> and nothing else.
Since you are using shared memory, another (untested) solution could be
to let the singleton data be instantiated in shared memory together
with a reference count. A singleton is simply a proxy for this data,
and the reference count is use to track which singleton should create
or destroy the data.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk