Update of /cvsroot/boost-sandbox/boost-sandbox/boost/thread_safe_signals/detail
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20359/boost/thread_safe_signals/detail
Modified Files:
slot_call_iterator.hpp slot_template.hpp
Log Message:
Made slots throw bad_weak_ptr when called with expired tracked
objects. Combiners now have to catch bad_weak_ptr exceptions
thrown on slot iterator dereference. Tracking works automatically
now for slots that call other slots.
Index: slot_call_iterator.hpp
===================================================================
RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/thread_safe_signals/detail/slot_call_iterator.hpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- slot_call_iterator.hpp 1 Mar 2007 15:57:25 -0000 1.22
+++ slot_call_iterator.hpp 2 Mar 2007 22:04:47 -0000 1.23
@@ -20,6 +20,7 @@
#include <boost/thread_safe_signals/connection.hpp>
#include <boost/thread_safe_signals/slot_base.hpp>
#include <boost/type_traits.hpp>
+#include <boost/weak_ptr.hpp>
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
@@ -62,7 +63,15 @@
dereference() const
{
if (!(*cache)) {
- cache->reset(f(*iter));
+ try
+ {
+ cache->reset(f(*iter));
+ }
+ catch(const bad_weak_ptr &err)
+ {
+ (*iter)->nolock_disconnect();
+ throw;
+ }
}
return cache->get();
}
@@ -91,7 +100,6 @@
for(;iter != end; ++iter)
{
lock_type lock((*iter)->mutex);
- tracked_ptrs = (*iter)->nolock_grab_tracked_objects();
if((*iter)->nolock_nograb_blocked() == false)
{
callable_iter = iter;
@@ -109,7 +117,6 @@
Function f;
optional<result_type>* cache;
mutable Iterator callable_iter;
- mutable typename slot_base::locked_container_type tracked_ptrs;
};
} // end namespace detail
} // end namespace BOOST_SIGNALS_NAMESPACE
Index: slot_template.hpp
===================================================================
RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/thread_safe_signals/detail/slot_template.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- slot_template.hpp 2 Mar 2007 19:34:30 -0000 1.6
+++ slot_template.hpp 2 Mar 2007 22:04:47 -0000 1.7
@@ -48,18 +48,6 @@
BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)(const F& f): _slot_function(signalslib::detail::get_invocable_slot(f, signalslib::detail::tag_type(f)))
{
}
- // copy constructors
- template<BOOST_SIGNAL_PREFIXED_SIGNATURE_TEMPLATE_DECL(BOOST_SIGNALS_NUM_ARGS, Other), typename OtherSlotFunction>
- BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)(const BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)
- <BOOST_SIGNAL_PREFIXED_SIGNATURE_TEMPLATE_INSTANTIATION(BOOST_SIGNALS_NUM_ARGS, Other), OtherSlotFunction> &other_slot):
- signalslib::detail::slot_base(other_slot), _slot_function(other_slot._slot_function)
- {
- }
- template<typename Signature, typename OtherSlotFunction>
- BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)(const slot<Signature, OtherSlotFunction> &other_slot):
- signalslib::detail::slot_base(other_slot), _slot_function(other_slot._slot_function)
- {
- }
// bind syntactic sugar
// ArgTypeN argN
#define BOOST_SLOT_BINDING_ARG_DECL(z, n, data) \
@@ -77,10 +65,12 @@
#undef BOOST_SLOT_BINDING_CONSTRUCTOR
R operator()(BOOST_SIGNAL_SIGNATURE_FULL_ARGS(BOOST_SIGNALS_NUM_ARGS))
{
+ locked_container_type locked_objects = lock();
return _slot_function(BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
}
R operator()(BOOST_SIGNAL_SIGNATURE_FULL_ARGS(BOOST_SIGNALS_NUM_ARGS)) const
{
+ locked_container_type locked_objects = lock();
return _slot_function(BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS));
}
BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)& track(const weak_ptr<void> &tracked)
@@ -88,15 +78,6 @@
_trackedObjects.push_back(tracked);
return *this;
}
- BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)& track(const slot_base &slot)
- {
- tracked_container_type::const_iterator it;
- for(it = slot.tracked_objects().begin(); it != slot.tracked_objects().end(); ++it)
- {
- track(*it);
- }
- return *this;
- }
BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)& track(const signalslib::detail::signal_base &signal)
{
// call base class function, since it is a friend of signal_base and can call lock_pimpl()
|