Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49068 - in sandbox/thread_safe_signals/trunk: boost/signals2 libs/signals2/doc/reference libs/signals2/test
From: fmhess_at_[hidden]
Date: 2008-09-30 11:35:43


Author: fmhess
Date: 2008-09-30 11:35:42 EDT (Tue, 30 Sep 2008)
New Revision: 49068
URL: http://svn.boost.org/trac/boost/changeset/49068

Log:
Simplified behavior of scoped_connection::release. Removed swaps
for scoped_connection since the base class swaps work fine for
scoped_connection too now.

Text files modified:
   sandbox/thread_safe_signals/trunk/boost/signals2/connection.hpp | 26 +++--------------
   sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/connection.xml | 58 +++++++++------------------------------
   sandbox/thread_safe_signals/trunk/libs/signals2/test/connection_test.cpp | 3 +
   3 files changed, 21 insertions(+), 66 deletions(-)

Modified: sandbox/thread_safe_signals/trunk/boost/signals2/connection.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/connection.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/connection.hpp 2008-09-30 11:35:42 EDT (Tue, 30 Sep 2008)
@@ -198,46 +198,30 @@
     class scoped_connection: public connection
     {
     public:
- scoped_connection(): _released(false) {}
+ scoped_connection() {}
       scoped_connection(const connection &other):
- connection(other), _released(false)
+ connection(other)
       {}
       ~scoped_connection()
       {
- if(_released == false)
- disconnect();
+ disconnect();
       }
       scoped_connection& operator=(const connection &rhs)
       {
- if(_released == false)
- disconnect();
- _released = false;
+ disconnect();
         connection::operator=(rhs);
         return *this;
       }
       connection release()
       {
         connection conn(_weak_connection_body);
- _released = true;
+ _weak_connection_body.reset();
         return conn;
       }
- bool released() const {return _released;}
- void swap(scoped_connection &other)
- {
- connection::swap(other);
- using std::swap;
- swap(_released, other._released);
- }
     private:
       scoped_connection(const scoped_connection &other);
       scoped_connection& operator=(const scoped_connection &rhs);
-
- bool _released;
     };
- void swap(scoped_connection &conn1, scoped_connection &conn2)
- {
- conn1.swap(conn2);
- }
   }
 }
 

Modified: sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/connection.xml
==============================================================================
--- sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/connection.xml (original)
+++ sandbox/thread_safe_signals/trunk/libs/signals2/doc/reference/connection.xml 2008-09-30 11:35:42 EDT (Tue, 30 Sep 2008)
@@ -168,7 +168,7 @@
         <access name="public">
           <constructor>
             <postconditions>
- <para><code><methodname>released</methodname>() == false &amp;&amp; <methodname alt="connection::connected">connected</methodname>() == false </code></para>
+ <para><code><methodname alt="connection::connected">connected</methodname>() == false </code></para>
             </postconditions>
             <description>
               <para>Default constructs an empty scoped_connection.</para>
@@ -186,7 +186,7 @@
               <computeroutput>other</computeroutput>.</para></effects>
 
             <postconditions>
- <para><code><methodname>released</methodname>() == false &amp;&amp; <methodname alt="connection::connected">connected</methodname>() == other.connected()</code></para>
+ <para><code><methodname alt="connection::connected">connected</methodname>() == other.connected()</code></para>
             </postconditions>
 
             <throws><para>Will not throw.</para></throws>
@@ -194,8 +194,7 @@
 
           <destructor>
             <effects><para>If
- <computeroutput>this-&gt;<methodname alt="connection::connected">connected</methodname>()</computeroutput>
- and this-><methodname>released</methodname>() == false,
+ <computeroutput>this-&gt;<methodname alt="connection::connected">connected</methodname>()</computeroutput>,
             disconnects the signal-slot connection.</para></effects>
           </destructor>
           <method-group name="public methods">
@@ -208,46 +207,31 @@
                 <para><computeroutput>this</computeroutput> references
                   the connection referenced by
                   <computeroutput>rhs</computeroutput>. If <code>this</code> already references another
- connection which has not been released, the old connection will be disconnected first.
+ connection, the old connection will be disconnected first.
                 </para>
               </effects>
               <postconditions>
- <para><code><methodname>released</methodname>() == false &amp;&amp; <methodname alt="connection::connected">connected</methodname>() == rhs.connected()</code></para>
+ <para><code><methodname alt="connection::connected">connected</methodname>() == rhs.connected()</code></para>
               </postconditions>
             </method>
             <method name="release">
               <type><classname>connection</classname></type>
- <postconditions>
- <para><code>released() == true</code></para>
- </postconditions>
               <effects>
                 <para>
- Prevents the <code>scoped_connection</code> from disconnecting when the
- it is destroyed or reassigned.
+ Releases the connection so it will not be disconnected by the <code>scoped_connection</code>
+ when it is destroyed or reassigned. The <code>scoped_connection</code> is reset to
+ the NULL connection after this call completes.
                 </para>
               </effects>
- </method>
- <method name="released" cv="const">
- <type>bool</type>
+ <postconditions>
+ <para><code><methodname alt="connection::connected">connected</methodname>() == false</code></para>
+ </postconditions>
               <returns>
- <para>
- Returns <code>false</code> if the scoped_connection will disconnect the connection when the
- <code>scoped_connection</code> is destroyed or reassigned. Otherwise, returns <code>true</code>.
+ <para>A <classname>connection</classname> object referencing the connection which was
+ released by the <code>scoped_connection</code>.
                 </para>
               </returns>
             </method>
- <method name="swap">
- <type>void</type>
- <parameter name="other">
- <paramtype>const <classname>scoped_connection</classname>&amp;</paramtype>
- </parameter>
- <effects><para>Swaps the connections referenced in
- <computeroutput>this</computeroutput> and
- <computeroutput>other</computeroutput>, as well as their "released" state
- (see the <methodname>released</methodname> method).</para></effects>
-
- <throws><para>Will not throw.</para></throws>
- </method>
           </method-group>
         </access>
         <access name="private">
@@ -274,7 +258,7 @@
             <title>Thread Safety</title>
             <para>The methods of the <code>scoped_connection</code> class (including those
               inherited from its base <code>connection</code> class) are thread-safe with the exception
- of <methodname>swap</methodname>, <methodname>release</methodname>, and
+ of <methodname>connection::swap</methodname>, <methodname>release</methodname>, and
               the assignment operator A <code>scoped_connection</code> object
               should not be accessed concurrently when any of these operations is in progress.
               However, it is always safe to access a different <code>connection</code> object
@@ -282,20 +266,6 @@
             </para>
           </section>
         </description>
- <free-function-group name="specialized algorithms">
- <function name="swap">
- <type>void</type>
- <parameter name="x">
- <paramtype><classname>scoped_connection</classname>&amp;</paramtype>
- </parameter>
- <parameter name="y">
- <paramtype><classname>scoped_connection</classname>&amp;</paramtype>
- </parameter>
-
- <effects><para><computeroutput>x.swap(y)</computeroutput></para></effects>
- <throws><para>Will not throw.</para></throws>
- </function>
- </free-function-group>
       </class>
     </namespace>
   </namespace>

Modified: sandbox/thread_safe_signals/trunk/libs/signals2/test/connection_test.cpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/libs/signals2/test/connection_test.cpp (original)
+++ sandbox/thread_safe_signals/trunk/libs/signals2/test/connection_test.cpp 2008-09-30 11:35:42 EDT (Tue, 30 Sep 2008)
@@ -71,8 +71,9 @@
     bs2::scoped_connection scoped(conn);
     BOOST_CHECK(scoped.connected());
     conn = scoped.release();
- conn.disconnect();
+ BOOST_CHECK(conn.connected());
     BOOST_CHECK(scoped.connected() == false);
+ conn.disconnect();
 
     // earlier release shouldn't affect new connection
     bs2::connection conn2 = sig.connect(&myslot);


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