Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50253 - sandbox/thread_safe_signals/trunk/boost/signals2/detail
From: fmhess_at_[hidden]
Date: 2008-12-12 16:48:19


Author: fmhess
Date: 2008-12-12 16:48:19 EST (Fri, 12 Dec 2008)
New Revision: 50253
URL: http://svn.boost.org/trac/boost/changeset/50253

Log:
Optimized invocation speed with respect to overhead from copying signal arguments.

Text files modified:
   sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp | 12 ++++++------
   sandbox/thread_safe_signals/trunk/boost/signals2/detail/slot_call_iterator.hpp | 17 ++++++++++-------
   2 files changed, 16 insertions(+), 13 deletions(-)

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp 2008-12-12 16:48:19 EST (Fri, 12 Dec 2008)
@@ -262,10 +262,10 @@
           }
           slot_invoker invoker BOOST_PP_IF(BOOST_SIGNALS_NUM_ARGS, \
             (BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS)), );
- slot_call_iterator_cache<slot_result_type> cache;
+ slot_call_iterator_cache<slot_result_type, slot_invoker> cache(invoker);
           return local_state->combiner(
- slot_call_iterator(local_state->connection_bodies.begin(), local_state->connection_bodies.end(), invoker, cache),
- slot_call_iterator(local_state->connection_bodies.end(), local_state->connection_bodies.end(), invoker, cache));
+ slot_call_iterator(local_state->connection_bodies.begin(), local_state->connection_bodies.end(), cache),
+ slot_call_iterator(local_state->connection_bodies.end(), local_state->connection_bodies.end(), cache));
         }
         result_type operator ()(BOOST_SIGNAL_SIGNATURE_FULL_ARGS(BOOST_SIGNALS_NUM_ARGS)) const
         {
@@ -283,10 +283,10 @@
           }
           slot_invoker invoker BOOST_PP_IF(BOOST_SIGNALS_NUM_ARGS, \
             (BOOST_SIGNAL_SIGNATURE_ARG_NAMES(BOOST_SIGNALS_NUM_ARGS)), );
- slot_call_iterator_cache<slot_result_type> cache;
+ slot_call_iterator_cache<slot_result_type, slot_invoker> cache(invoker);
           return const_cast<const combiner_type&>(local_state->combiner)(
- slot_call_iterator(local_state->connection_bodies.begin(), local_state->connection_bodies.end(), invoker, cache),
- slot_call_iterator(local_state->connection_bodies.end(), local_state->connection_bodies.end(), invoker, cache));
+ slot_call_iterator(local_state->connection_bodies.begin(), local_state->connection_bodies.end(), cache),
+ slot_call_iterator(local_state->connection_bodies.end(), local_state->connection_bodies.end(), cache));
         }
         std::size_t num_slots() const
         {

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-12-12 16:48:19 EST (Fri, 12 Dec 2008)
@@ -27,13 +27,17 @@
 namespace boost {
   namespace signals2 {
     namespace detail {
- template<typename ResultType>
+ template<typename ResultType, typename Function>
         class slot_call_iterator_cache
       {
       public:
+ slot_call_iterator_cache(const Function &f):
+ f(f)
+ {}
         optional<ResultType> result;
         typedef stack_vector<boost::shared_ptr<void>, 10> tracked_ptrs_type;
         tracked_ptrs_type tracked_ptrs;
+ Function f;
       };
 
       // Generates a slot call iterator. Essentially, this is an iterator that:
@@ -58,9 +62,9 @@
         friend class boost::iterator_core_access;
 
       public:
- slot_call_iterator_t(Iterator iter_in, Iterator end_in, Function f,
- slot_call_iterator_cache<result_type> &c):
- iter(iter_in), end(end_in), f(f),
+ slot_call_iterator_t(Iterator iter_in, Iterator end_in,
+ slot_call_iterator_cache<result_type, Function> &c):
+ iter(iter_in), end(end_in),
           cache(&c), callable_iter(end_in)
         {
           lock_next_callable();
@@ -72,7 +76,7 @@
           if (!cache->result) {
             try
             {
- cache->result.reset(f(*iter));
+ cache->result.reset(cache->f(*iter));
             }
             catch(expired_slot &)
             {
@@ -123,8 +127,7 @@
 
         mutable Iterator iter;
         Iterator end;
- Function f;
- slot_call_iterator_cache<result_type> *cache;
+ slot_call_iterator_cache<result_type, Function> *cache;
         mutable Iterator callable_iter;
       };
     } // end namespace detail


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