|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53154 - in branches/release: boost/signals2 libs/signals2/doc/reference libs/signals2/test
From: fmhess_at_[hidden]
Date: 2009-05-21 10:44:02
Author: fmhess
Date: 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
New Revision: 53154
URL: http://svn.boost.org/trac/boost/changeset/53154
Log:
Merged changesets [53091], [53128], [53130], [53131], and [53132]
from trunk to release.
Added:
branches/release/libs/signals2/test/shared_connection_block_test.cpp
- copied, changed from r53128, /trunk/libs/signals2/test/shared_connection_block_test.cpp
Text files modified:
branches/release/boost/signals2/connection.hpp | 4 ++
branches/release/boost/signals2/shared_connection_block.hpp | 9 ++++-
branches/release/libs/signals2/doc/reference/connection.xml | 11 ++++++
branches/release/libs/signals2/doc/reference/shared_connection_block.xml | 69 +++++++++++++++++++++++++++++++++++----
branches/release/libs/signals2/test/Jamfile.v2 | 3 +
branches/release/libs/signals2/test/deletion_test.cpp | 30 -----------------
branches/release/libs/signals2/test/shared_connection_block_test.cpp | 16 ++++++++
7 files changed, 100 insertions(+), 42 deletions(-)
Modified: branches/release/boost/signals2/connection.hpp
==============================================================================
--- branches/release/boost/signals2/connection.hpp (original)
+++ branches/release/boost/signals2/connection.hpp 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
@@ -178,6 +178,10 @@
boost::shared_ptr<detail::connection_body_base> otherConnectionBody(other._weak_connection_body.lock());
return connectionBody == otherConnectionBody;
}
+ bool operator!=(const connection& other) const
+ {
+ return !(*this == other);
+ }
bool operator<(const connection& other) const
{
boost::shared_ptr<detail::connection_body_base> connectionBody(_weak_connection_body.lock());
Modified: branches/release/boost/signals2/shared_connection_block.hpp
==============================================================================
--- branches/release/boost/signals2/shared_connection_block.hpp (original)
+++ branches/release/boost/signals2/shared_connection_block.hpp 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
@@ -22,10 +22,11 @@
class shared_connection_block
{
public:
- shared_connection_block(const connection &conn):
+ shared_connection_block(const signals2::connection &conn = signals2::connection(),
+ bool initially_blocked = true):
_weak_connection_body(conn._weak_connection_body)
{
- block();
+ if(initially_blocked) block();
}
void block()
{
@@ -49,6 +50,10 @@
shared_ptr<void> empty;
return _blocker < empty || empty < _blocker;
}
+ signals2::connection connection() const
+ {
+ return signals2::connection(_weak_connection_body);
+ }
private:
boost::weak_ptr<detail::connection_body_base> _weak_connection_body;
shared_ptr<void> _blocker;
Modified: branches/release/libs/signals2/doc/reference/connection.xml
==============================================================================
--- branches/release/libs/signals2/doc/reference/connection.xml (original)
+++ branches/release/libs/signals2/doc/reference/connection.xml 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
@@ -131,6 +131,17 @@
<throws><para>Will not throw.</para></throws>
</method>
+ <method name="operator!=" cv="const">
+ <type>bool</type>
+ <parameter name="other">
+ <paramtype>const <classname>connection</classname>&</paramtype>
+ </parameter>
+
+ <returns><para><computeroutput>!(*this == other)</computeroutput></para></returns>
+
+ <throws><para>Will not throw.</para></throws>
+ </method>
+
<method name="operator<" cv="const">
<type>bool</type>
<parameter name="other">
Modified: branches/release/libs/signals2/doc/reference/shared_connection_block.xml
==============================================================================
--- branches/release/libs/signals2/doc/reference/shared_connection_block.xml (original)
+++ branches/release/libs/signals2/doc/reference/shared_connection_block.xml 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
@@ -42,23 +42,68 @@
</para>
</description>
- <constructor>
+ <constructor>
<parameter name="conn">
- <paramtype>const boost::signals2::connection &</paramtype>
+ <paramtype>const <classname>boost::signals2::connection</classname> &</paramtype>
+ <default>connection()</default>
+ </parameter>
+ <parameter name="initially_blocking">
+ <paramtype>bool</paramtype>
+ <default>true</default>
+ </parameter>
+
+ <effects>
+ <para>Creates a <code>shared_connection_block</code> which can block
+ the connection referenced by <code>conn</code>. The <code>shared_connection_block</code>
+ will initially block the connection if and only if the
+ <code>initially_blocking</code>
+ parameter is <code>true</code>. The block on the connection may be released
+ by calling the <methodname>unblock</methodname> method,
+ or destroying the <code>shared_connection_block</code> object.</para>
+ <para>Default construction of a <code>shared_connection_block</code> results in a
+ <code>shared_connection_block</code> which references the NULL connection.
+ Such a <code>shared_connection_block</code> is safe to use, though not
+ particularly useful until it is assigned another
+ <code>shared_connection_block</code> which references a real connection.
+ </para>
+ </effects>
+ <postconditions><para><code>this->blocking() == initially_blocking</code></para></postconditions>
+ </constructor>
+ <constructor>
+ <parameter name="other">
+ <paramtype>const boost::signals2::shared_connection_block &</paramtype>
</parameter>
<effects>
- <para>Creates a <code>shared_connection_block</code> which references
- the connection referenced by <code>conn</code>. The connection will
- initially be blocked, and remain so
- until <methodname>unblock</methodname> is called,
- or the <code>shared_connection_block</code> is destroyed.</para>
+ <para>
+ Copy constructs a <code>shared_connection_block</code> which references
+ the same connection as <code>other</code>.
+ </para>
</effects>
- <postconditions><para><code>this->blocking() == true</code></para></postconditions>
+ <postconditions>
+ <para><code>this->connection() == other.connection()</code></para>
+ <para><code>this->blocking() == other.blocking()</code></para>
+ </postconditions>
</constructor>
<destructor>
<effects><para>If <methodname>blocking</methodname>() is true, releases the connection block.</para></effects>
</destructor>
+ <copy-assignment>
+ <parameter name="rhs">
+ <paramtype>const boost::signals2::shared_connection_block &</paramtype>
+ </parameter>
+
+ <effects>
+ <para>
+ Makes <code>this</code> reference the same connection as <code>rhs</code>.
+ </para>
+ </effects>
+ <postconditions>
+ <para><code>this->connection() == rhs.connection()</code></para>
+ <para><code>this->blocking() == rhs.blocking()</code></para>
+ </postconditions>
+ <throws><para>Will not throw.</para></throws>
+ </copy-assignment>
<method-group name="connection blocking">
<method name="unblock">
<type>void</type>
@@ -82,6 +127,14 @@
blocked by another <code>shared_connection_block</code> object.</para></notes>
</method>
</method-group>
+ <method-group name="miscellaneous methods">
+ <method name="connection" cv="const">
+ <type><classname>boost::signals2::connection</classname></type>
+ <returns>
+ <para>A connection object for the connection referenced by <code>this</code>.</para>
+ </returns>
+ </method>
+ </method-group>
</class>
</namespace>
</namespace>
Modified: branches/release/libs/signals2/test/Jamfile.v2
==============================================================================
--- branches/release/libs/signals2/test/Jamfile.v2 (original)
+++ branches/release/libs/signals2/test/Jamfile.v2 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
@@ -1,4 +1,4 @@
-# Boost.Signals2 Library
+# Boost.Signals2 Library
# Copyright Douglas Gregor 2001-2003.
# Copyright Frank Mori Hess 2009.
@@ -38,6 +38,7 @@
[ thread-run mutex_test.cpp ]
[ run ordering_test.cpp ]
[ run regression_test.cpp ]
+ [ run shared_connection_block_test.cpp ]
[ run signal_n_test.cpp ]
[ run signal_test.cpp ]
[ run signal_type_test.cpp ]
Modified: branches/release/libs/signals2/test/deletion_test.cpp
==============================================================================
--- branches/release/libs/signals2/test/deletion_test.cpp (original)
+++ branches/release/libs/signals2/test/deletion_test.cpp 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
@@ -93,36 +93,6 @@
s0(); std::cout << std::endl;
BOOST_CHECK(test_output == "123");
- std::cout << "Blocking 2" << std::endl;
-
- {
- boost::signals2::shared_connection_block block(connections[2]);
- test_output = "";
- s0(); std::cout << std::endl;
- BOOST_CHECK(test_output == "13");
- }
-
- std::cout << "Unblocking 2" << std::endl;
-
- test_output = "";
- s0(); std::cout << std::endl;
- BOOST_CHECK(test_output == "123");
-
- std::cout << "Blocking 1 through const connection" << std::endl;
-
- {
- const boost::signals2::connection conn = connections[1];
- boost::signals2::shared_connection_block block(conn);
- test_output = "";
- s0(); std::cout << std::endl;
- BOOST_CHECK(test_output == "23");
- std::cout << "Unblocking 1" << std::endl;
- block.unblock();
- test_output = "";
- s0(); std::cout << std::endl;
- BOOST_CHECK(test_output == "123");
- }
-
s0.disconnect_all_slots();
BOOST_CHECK(s0.empty());
Copied: branches/release/libs/signals2/test/shared_connection_block_test.cpp (from r53128, /trunk/libs/signals2/test/shared_connection_block_test.cpp)
==============================================================================
--- /trunk/libs/signals2/test/shared_connection_block_test.cpp (original)
+++ branches/release/libs/signals2/test/shared_connection_block_test.cpp 2009-05-21 10:44:00 EDT (Thu, 21 May 2009)
@@ -86,13 +86,27 @@
}
{
- // default construction
+ // test default constructed block
boost::signals2::shared_connection_block block;
BOOST_CHECK(block.blocking() == true);
block.unblock();
BOOST_CHECK(block.blocking() == false);
block.block();
BOOST_CHECK(block.blocking() == true);
+
+ // test assignment
+ {
+ block.unblock();
+ boost::signals2::shared_connection_block block2(connections.at(0));
+ BOOST_CHECK(block.connection() != block2.connection());
+ BOOST_CHECK(block.blocking() != block2.blocking());
+ block = block2;
+ BOOST_CHECK(block.connection() == block2.connection());
+ BOOST_CHECK(block.blocking() == block2.blocking());
+ }
+ test_output.str("");
+ s0();
+ BOOST_CHECK(test_output.str() == "123");
}
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