
Hello again everyone!
Boo ST == (Scarey signals & threads)
Signals/slots are just too good not to use in a multi-threaded environment.
Someday, this will be fixed, I know. But for now...
I'm trying to serialize access to boost.signals using Bjarne Stroustrups
"wrapper" concept.
Here's what I'm doing. Is this likely to cause problems? Sorry about the
length.
If this is too dangerous, what's a better alternative?
I typed this from memory and didn't try to compile.
Please disregard any typos or syntactic blunders.
// Implements Bjarne Stroustrup's "wrapper" concept using boost::shared_ptr.
template <typename T> class Wrapper {
T* p;
public:
explicit Wrapper(T& obj) : p(&obj) { }
boost::shared_ptr<T> get() const {
p->prefix();
return boost::shared_ptr<T>(p, boost::mem_fn(&T::suffix));
} // get
boost::shared_ptr<T> operator->() const { return get(); }
}; //Wrapper
// Provides signals through "safe" wrapper. (?)
class TiePoint {
public:
class Events {
Mutex lock; // Provided elsewhere.
void prefix() { lock.acquire(); }
void suffix() { lock.release(); }
friend class Wrapper<Events>;
public:
boost::signal