Boost logo

Boost Users :

From: Allison Floyd (allison.floyd_at_[hidden])
Date: 2007-01-25 12:44:29


Hello, the list.

After some digging through the bind and mem_fn documentation, I have
been unable to figure out whether I'm attempting to do something
impossible or not. I've created a thread-safe variant of shared_ptr
that uses Alexandrescu's LockingProxy to ensure that access to the
contained object through operator-> correctly locks and unlocks the
pointee object. In all respects save one, this "shared_locking_ptr"
is syntactically equivalent to boost::shared_ptr. The one thing it
cannot do is dereference the pointer via operator* (I can't figure out
how to return something from operator* that remains in scope (and thus
locked) long enough for the operation to complete). All well and good
so far.

Where I'm trying to use this beast is in boost::signals via bind (and
therefore mem_fn). I'd like to connect a member function of an object
to the signal through my shared_locking_ptr, so that when the signal
fires it automatically locks the object, invokes the member function,
and then unlocks. Shared pointers to objects are valid arguments to
mem_fn; my shared_locking_ptr isn't, alas, apparently because it
requires the operator* mentioned above.

So: 1) Has anybody else attempted to extend shared_ptr for
Alexandrescu's policy-based storage types, specifically the
LockingProxy, and figured out how to overload operator* in a
meaningful way? or 2) Is there some way to wheedle signals, bind,
and/or mem_fn so that they only access the slot through operator->,
and don't try to dereference it?

If this is more properly a boost developer's list question, let me
know and I'll take it there.

Thanks!

--
Allison Floyd

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