Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85836 - in trunk: boost/signals2/detail libs/signals2/doc libs/signals2/doc/reference libs/signals2/test
From: fmhess_at_[hidden]
Date: 2013-09-22 17:21:34


Author: fmhess
Date: 2013-09-22 17:21:34 EDT (Sun, 22 Sep 2013)
New Revision: 85836
URL: http://svn.boost.org/trac/boost/changeset/85836

Log:
Don't force disconnection of all slots in signal destructor.
Refs #9103

Text files modified:
   trunk/boost/signals2/detail/signal_template.hpp | 1
   trunk/libs/signals2/doc/porting.xml | 14 ++++++++++
   trunk/libs/signals2/doc/reference/signal_header.xml | 4 ---
   trunk/libs/signals2/test/deletion_test.cpp | 48 ++++++++++++++++++++++++++++++++++++++++
   4 files changed, 61 insertions(+), 6 deletions(-)

Modified: trunk/boost/signals2/detail/signal_template.hpp
==============================================================================
--- trunk/boost/signals2/detail/signal_template.hpp Sun Sep 22 15:02:08 2013 (r85835)
+++ trunk/boost/signals2/detail/signal_template.hpp 2013-09-22 17:21:34 EDT (Sun, 22 Sep 2013) (r85836)
@@ -657,7 +657,6 @@
       {};
       virtual ~BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)()
       {
- disconnect_all_slots();
       }
       connection connect(const slot_type &slot, connect_position position = at_back)
       {

Modified: trunk/libs/signals2/doc/porting.xml
==============================================================================
--- trunk/libs/signals2/doc/porting.xml Sun Sep 22 15:02:08 2013 (r85835)
+++ trunk/libs/signals2/doc/porting.xml 2013-09-22 17:21:34 EDT (Sun, 22 Sep 2013) (r85836)
@@ -227,8 +227,20 @@
   </section>
   <section id="signals2.api_history">
     <title>Signals2 API Development</title>
+ <section id="signals2.api_history.1-56">
+ <title>Version 1.56</title>
+ <para>
+ Version 1.56 modified the behavior of the signal destructor, in that it no longer
+ explicitly calls disconnect_all_slots. Any signal invocations running
+ concurrently with the signal destructor should now complete normally, rather
+ than skipping all remaining slots. Once all concurrent signal invocations
+ complete, all connections to the deleted signal will still ultimately
+ be disconnected. This change brings Boost.Signals2
+ behavior closer to the behavior of the original Boost.Signals library.
+ </para>
+ </section>
     <section id="signals2.api_history.1-45">
- <title>Version 1.4x</title>
+ <title>Version 1.45</title>
       <para>
         Version 1.45 added <methodname>slot::track_foreign</methodname>(). This method allows tracking
         of objects owned by <code>shared_ptr</code> classes other than <classname>boost::shared_ptr</classname>,

Modified: trunk/libs/signals2/doc/reference/signal_header.xml
==============================================================================
--- trunk/libs/signals2/doc/reference/signal_header.xml Sun Sep 22 15:02:08 2013 (r85835)
+++ trunk/libs/signals2/doc/reference/signal_header.xml 2013-09-22 17:21:34 EDT (Sun, 22 Sep 2013) (r85836)
@@ -140,10 +140,6 @@
           <postconditions><para><computeroutput>this-&gt;<methodname>empty</methodname>()</computeroutput></para></postconditions>
         </constructor>
 
- <destructor>
- <effects><para>Disconnects all slots connected to <computeroutput>*this</computeroutput>.</para></effects>
- </destructor>
-
         <method-group name="connection management">
           <overloaded-method name="connect">
             <signature>

Modified: trunk/libs/signals2/test/deletion_test.cpp
==============================================================================
--- trunk/libs/signals2/test/deletion_test.cpp Sun Sep 22 15:02:08 2013 (r85835)
+++ trunk/libs/signals2/test/deletion_test.cpp 2013-09-22 17:21:34 EDT (Sun, 22 Sep 2013) (r85836)
@@ -238,6 +238,53 @@
   BOOST_CHECK(test_output == "013");
 }
 
+struct signal_deletion_tester
+{
+public:
+ signal_deletion_tester() {
+ b_has_run = false;
+ sig = new boost::signals2::signal<void(void)>();
+ connection0 = sig->connect(0, boost::bind(&signal_deletion_tester::a, this));
+ connection1 = sig->connect(1, boost::bind(&signal_deletion_tester::b, this));
+ }
+
+ ~signal_deletion_tester()
+ {
+ if(sig != 0)
+ delete sig;
+ }
+
+ void a()
+ {
+ if(sig != 0)
+ delete sig;
+ sig = 0;
+ }
+
+ void b()
+ {
+ b_has_run = true;
+ }
+
+ boost::signals2::signal<void(void)> *sig;
+ bool b_has_run;
+ boost::signals2::connection connection1;
+ boost::signals2::connection connection2;
+};
+
+// If a signal is deleted mid-invocation, the invocation in progress
+// should complete normally. Once all invocations complete, all
+// slots which were connected to the deleted signal should be in the
+// disconnected state.
+static void test_signal_deletion()
+{
+ signal_deletion_tester tester;
+ (*tester.sig)();
+ BOOST_CHECK(tester.b_has_run);
+ BOOST_CHECK(tester.connection0.connected() == false);
+ BOOST_CHECK(tester.connection1.connected() == false);
+}
+
 int test_main(int, char* [])
 {
   test_remove_self();
@@ -245,5 +292,6 @@
   test_remove_after();
   test_bloodbath();
   test_disconnect_equal();
+ test_signal_deletion();
   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