Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49035 - in sandbox/thread_safe_signals/trunk: boost/signals2 boost/signals2/detail libs/signals2/test
From: fmhess_at_[hidden]
Date: 2008-09-29 16:31:52


Author: fmhess
Date: 2008-09-29 16:31:51 EDT (Mon, 29 Sep 2008)
New Revision: 49035
URL: http://svn.boost.org/trac/boost/changeset/49035

Log:
Combiners don't have to catch expired_slot anymore.

Text files modified:
   sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_call_iterator.hpp | 10 +---------
   sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_template.hpp | 1 +
   sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp | 15 ++-------------
   sandbox/thread_safe_signals/trunk/boost/signals2/slot.hpp | 20 ++++++++++++++++++++
   sandbox/thread_safe_signals/trunk/libs/signals2/test/track_test.cpp | 17 ++++++-----------
   5 files changed, 30 insertions(+), 33 deletions(-)

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_call_iterator.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_call_iterator.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_call_iterator.hpp 2008-09-29 16:31:51 EDT (Mon, 29 Sep 2008)
@@ -60,15 +60,7 @@
         dereference() const
         {
           if (!(*cache)) {
- try
- {
- cache->reset(f(*iter));
- }
- catch(const expired_slot &)
- {
- (*iter)->disconnect();
- throw;
- }
+ cache->reset(f(*iter));
           }
           return cache->get();
         }

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_template.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_template.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_template.hpp 2008-09-29 16:31:51 EDT (Mon, 29 Sep 2008)
@@ -49,6 +49,7 @@
       template<typename F>
       BOOST_SLOT_CLASS_NAME(BOOST_SIGNALS_NUM_ARGS)(const F& f): _slot_function(detail::get_invocable_slot(f, detail::tag_type(f)))
       {
+ detail::auto_tracker<typename detail::get_slot_tag<F>::type> at(this, f);
       }
       // copy constructors
       template<BOOST_SIGNAL_PREFIXED_SIGNATURE_TEMPLATE_DECL(BOOST_SIGNALS_NUM_ARGS, Other), typename OtherSlotFunction>

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/last_value.hpp 2008-09-29 16:31:51 EDT (Mon, 29 Sep 2008)
@@ -17,7 +17,6 @@
 
 namespace boost {
   namespace signals2 {
- class expired_slot;
     // no_slots_error is thrown when we are unable to generate a return value
     // due to no slots being connected to the signal.
     class no_slots_error: public std::exception
@@ -52,12 +51,7 @@
         optional<T> value;
         while (first != last)
         {
- try
- {
- value = *first;
- }
- catch(const expired_slot &)
- {}
+ value = *first;
           ++first;
         }
         if(value) return value.get();
@@ -81,12 +75,7 @@
       {
         while (first != last)
         {
- try
- {
- *first;
- }
- catch(const expired_slot &)
- {}
+ *first;
           ++first;
         }
         return result_type();

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/slot.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/slot.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/slot.hpp 2008-09-29 16:31:51 EDT (Mon, 29 Sep 2008)
@@ -57,6 +57,26 @@
         the_tag_type tag = the_tag_type();
         return tag;
       }
+
+ // used to automatically track signal objects that are passed directly to slots
+ template<typename SlotTag>
+ class auto_tracker
+ {
+ public:
+ template<typename Slot, typename F>
+ auto_tracker(Slot *slot, const F &f)
+ {}
+ };
+ template<>
+ class auto_tracker<signal_tag>
+ {
+ public:
+ template<typename Slot, typename F>
+ auto_tracker(Slot *slot, const F &f)
+ {
+ slot->track(f);
+ }
+ };
     }
   }
 } // end namespace boost

Modified: sandbox/thread_safe_signals/trunk/libs/signals2/test/track_test.cpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/libs/signals2/test/track_test.cpp (original)
+++ sandbox/thread_safe_signals/trunk/libs/signals2/test/track_test.cpp 2008-09-29 16:31:51 EDT (Mon, 29 Sep 2008)
@@ -31,19 +31,14 @@
     boost::optional<T> max;
     for(; first != last; ++first)
     {
- try
+ T value = *first;
+ if(max == false)
       {
- T value = *first;
- if(max == false)
- {
- max = value;
- }else if(value > *max)
- {
- max = value;
- }
+ max = value;
+ }else if(value > *max)
+ {
+ max = value;
       }
- catch(const boost::signals2::expired_slot &)
- {}
     }
     if(max) return *max;
     else return T();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk