Boost logo

Boost Users :

Subject: [Boost-users] [Interprocess] Opposite of find_or_construct()
From: Aaron_Wright_at_[hidden]
Date: 2012-04-18 20:03:10


I feel like I'm missing something simple. I have multiple processes that
are going to use an object in shared memory. The find_or_construct()
method lets these processes get a pointer to the object without worrying
about startup order.

What about the opposite?

When a process is done with the object in shared memory it can't destroy
it because the other processes may be using it. Is there a
destroy_or_not() method that would only destroy the object when everyone
is done with it?

Normally I would solve this with a smart pointer like shared_ptr, but I
think I'm miss understanding smart_ptr and I can't get it to work right.
It seems like the shared_ptr is created in shared memory and needs to be
explicitly destroyed, which would bring me back to the original problem,
of who actually gets to destroy it.

Should I be looking at intrusive_ptr?

---
Aaron Wright


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