|
Boost Users : |
Subject: [Boost-users] Making friend with boost::interprocess
From: Oncaphillis (oncaphillis_at_[hidden])
Date: 2009-03-11 03:57:56
Hi,
I'd like to implement a cross-process singleton which resides in
a shared memory segment. So the basic idea is to provide a factory
method that is the only way to construct the Singleton.
e.g.
class Foo {
public:
static Foo & GetInstance() {
try {
boost::interprocess::managed_shared_memory
segment(
boost::interprocess::open_or_create,
"FooSegment",
65536);
void_allocator_t alloc(segment.get_segment_manager());
return *(segment.find_or_construct<Foo>(
"FooObject")(alloc));
} catch(std::exception & ex) {
throw;
}
}
private:
Foo(const void_allocator_t & a) {
...
...
}
Foo(const Foo &);
}
Of course somewhere deep in the guts of boost I get an error since
the Foo constructor is private. Who do I have to befriend in order
to make this scheme work ?
Thank you
O.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net