#include "signal_manager.h"
#include <boost/thread/mutex.hpp>
-#include <boost/signals2.hpp>
class WrapperBase
{
}
bool finished () const {
- boost::mutex::scoped_lock lm (_mutex);
+ boost::mutex::scoped_lock lm (_mutex, boost::try_to_lock);
+ if (!lm) {
+ /* It's possible that emission of this
+ wrapper's signal causes another signal to
+ be emitted, which causes finished() on this
+ wrapper to be called (by Signaller::emit).
+ In this case, just say that the wrapper is
+ not yet finished.
+ */
+ return false;
+ }
return _finished;
}
if (signal_manager) {
signal_manager->emit (boost::bind (&Wrapper<T>::signal, w));
}
-
+
boost::mutex::scoped_lock lm (_signaller_mutex);
/* Clean up finished Wrappers */