Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53599 - in trunk: boost/signals2/detail libs/signals2/test
From: fmhess_at_[hidden]
Date: 2009-06-03 09:43:52


Author: fmhess
Date: 2009-06-03 09:43:51 EDT (Wed, 03 Jun 2009)
New Revision: 53599
URL: http://svn.boost.org/trac/boost/changeset/53599

Log:
Added test for and fixed compile errors in signal::set_combiner()
and combiner() methods. Refs #3125.

Text files modified:
   trunk/boost/signals2/detail/signal_template.hpp | 4 ++--
   trunk/libs/signals2/test/signal_test.cpp | 29 +++++++++++++++++++++++++++++
   2 files changed, 31 insertions(+), 2 deletions(-)

Modified: trunk/boost/signals2/detail/signal_template.hpp
==============================================================================
--- trunk/boost/signals2/detail/signal_template.hpp (original)
+++ trunk/boost/signals2/detail/signal_template.hpp 2009-06-03 09:43:51 EDT (Wed, 03 Jun 2009)
@@ -288,13 +288,13 @@
         combiner_type combiner() const
         {
           unique_lock<mutex_type> lock(_mutex);
- return _shared_state->combiner;
+ return _shared_state->combiner();
         }
         void set_combiner(const combiner_type &combiner)
         {
           unique_lock<mutex_type> lock(_mutex);
           if(_shared_state.unique())
- _shared_state->combiner = combiner;
+ _shared_state->combiner() = combiner;
           else
             _shared_state.reset(new invocation_state(*_shared_state, combiner));
         }

Modified: trunk/libs/signals2/test/signal_test.cpp
==============================================================================
--- trunk/libs/signals2/test/signal_test.cpp (original)
+++ trunk/libs/signals2/test/signal_test.cpp 2009-06-03 09:43:51 EDT (Wed, 03 Jun 2009)
@@ -265,6 +265,34 @@
   BOOST_CHECK(typeid(unary_signal_type::slot_type::argument_type) == typeid(short));
 }
 
+class dummy_combiner
+{
+public:
+ typedef int result_type;
+
+ dummy_combiner(result_type return_value): _return_value(return_value)
+ {}
+ template<typename SlotIterator>
+ result_type operator()(SlotIterator, SlotIterator)
+ {
+ return _return_value;
+ }
+private:
+ result_type _return_value;
+};
+
+static void
+test_set_combiner()
+{
+ typedef boost::signals2::signal<int (), dummy_combiner> signal_type;
+ signal_type sig(dummy_combiner(0));
+ BOOST_CHECK(sig() == 0);
+ BOOST_CHECK(sig.combiner()(0,0) == 0);
+ sig.set_combiner(dummy_combiner(1));
+ BOOST_CHECK(sig() == 1);
+ BOOST_CHECK(sig.combiner()(0,0) == 1);
+}
+
 int
 test_main(int, char* [])
 {
@@ -275,5 +303,6 @@
   test_extended_slot<int>();
   test_reference_args();
   test_typedefs_etc();
+ test_set_combiner();
   return 0;
 }


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