|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72024 - in trunk/boost/asio: detail detail/impl ip ip/impl local
From: chris_at_[hidden]
Date: 2011-05-17 17:46:56
Author: chris_kohlhoff
Date: 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
New Revision: 72024
URL: http://svn.boost.org/trac/boost/changeset/72024
Log:
* Add move constructors and assignment operators to endpoint and address classes.
* Add support for platforms that have no signal support.
* Use using declarations when finding customisation hooks.
Text files modified:
trunk/boost/asio/detail/config.hpp | 7 ++++++
trunk/boost/asio/detail/handler_alloc_helpers.hpp | 4 +-
trunk/boost/asio/detail/handler_invoke_helpers.hpp | 4 +-
trunk/boost/asio/detail/impl/signal_set_service.ipp | 46 ++++++++++++++++++++++-----------------
trunk/boost/asio/ip/address.hpp | 10 ++++++++
trunk/boost/asio/ip/address_v4.hpp | 17 ++++++++++++++
trunk/boost/asio/ip/address_v6.hpp | 10 ++++++++
trunk/boost/asio/ip/basic_endpoint.hpp | 17 ++++++++++++++
trunk/boost/asio/ip/impl/address.ipp | 19 ++++++++++++++++
trunk/boost/asio/ip/impl/address_v6.ipp | 17 ++++++++++++++
trunk/boost/asio/local/basic_endpoint.hpp | 17 ++++++++++++++
11 files changed, 144 insertions(+), 24 deletions(-)
Modified: trunk/boost/asio/detail/config.hpp
==============================================================================
--- trunk/boost/asio/detail/config.hpp (original)
+++ trunk/boost/asio/detail/config.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -311,4 +311,11 @@
# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
#endif // !defined(BOOST_ASIO_DISABLE_SIGACTION)
+// Can use signal().
+#if !defined(BOOST_ASIO_DISABLE_SIGNAL)
+# if !defined(UNDER_CE)
+# define BOOST_ASIO_HAS_SIGNAL 1
+# endif // !defined(UNDER_CE)
+#endif // !defined(BOOST_ASIO_DISABLE_SIGNAL)
+
#endif // BOOST_ASIO_DETAIL_CONFIG_HPP
Modified: trunk/boost/asio/detail/handler_alloc_helpers.hpp
==============================================================================
--- trunk/boost/asio/detail/handler_alloc_helpers.hpp (original)
+++ trunk/boost/asio/detail/handler_alloc_helpers.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -35,7 +35,7 @@
|| BOOST_WORKAROUND(__GNUC__, < 3)
return ::operator new(s);
#else
- using namespace boost::asio;
+ using boost::asio::asio_handler_allocate;
return asio_handler_allocate(s, boost::addressof(h));
#endif
}
@@ -47,7 +47,7 @@
|| BOOST_WORKAROUND(__GNUC__, < 3)
::operator delete(p);
#else
- using namespace boost::asio;
+ using boost::asio::asio_handler_deallocate;
asio_handler_deallocate(p, s, boost::addressof(h));
#endif
}
Modified: trunk/boost/asio/detail/handler_invoke_helpers.hpp
==============================================================================
--- trunk/boost/asio/detail/handler_invoke_helpers.hpp (original)
+++ trunk/boost/asio/detail/handler_invoke_helpers.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -35,7 +35,7 @@
Function tmp(function);
tmp();
#else
- using namespace boost::asio;
+ using boost::asio::asio_handler_invoke;
asio_handler_invoke(function, boost::addressof(context));
#endif
}
@@ -48,7 +48,7 @@
Function tmp(function);
tmp();
#else
- using namespace boost::asio;
+ using boost::asio::asio_handler_invoke;
asio_handler_invoke(function, boost::addressof(context));
#endif
}
Modified: trunk/boost/asio/detail/impl/signal_set_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/signal_set_service.ipp (original)
+++ trunk/boost/asio/detail/impl/signal_set_service.ipp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -70,9 +70,9 @@
errno = saved_errno;
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
-#if !defined(BOOST_ASIO_HAS_SIGACTION)
+#if defined(BOOST_ASIO_HAS_SIGNAL) && !defined(BOOST_ASIO_HAS_SIGACTION)
signal(signal_number, asio_signal_handler);
-#endif // !defined(BOOST_ASIO_HAS_SIGACTION)
+#endif // defined(BOOST_ASIO_HAS_SIGNAL) && !defined(BOOST_ASIO_HAS_SIGACTION)
}
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
@@ -231,30 +231,32 @@
{
registration* new_registration = new registration;
+#if defined(BOOST_ASIO_HAS_SIGNAL) || defined(BOOST_ASIO_HAS_SIGACTION)
// Register for the signal if we're the first.
if (state->registration_count_[signal_number] == 0)
{
-#if defined(BOOST_ASIO_HAS_SIGACTION)
+# if defined(BOOST_ASIO_HAS_SIGACTION)
using namespace std; // For memset.
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = asio_signal_handler;
sigfillset(&sa.sa_mask);
if (::sigaction(signal_number, &sa, 0) == -1)
-#else // defined(BOOST_ASIO_HAS_SIGACTION)
+# else // defined(BOOST_ASIO_HAS_SIGACTION)
if (::signal(signal_number, asio_signal_handler) == SIG_ERR)
-#endif // defined(BOOST_ASIO_HAS_SIGACTION)
+# endif // defined(BOOST_ASIO_HAS_SIGACTION)
{
-#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
ec = boost::asio::error::invalid_argument;
-#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
ec = boost::system::error_code(errno,
boost::asio::error::get_system_category());
-#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
delete new_registration;
return ec;
}
}
+#endif // defined(BOOST_ASIO_HAS_SIGNAL) || defined(BOOST_ASIO_HAS_SIGACTION)
// Record the new registration in the set.
new_registration->signal_number_ = signal_number;
@@ -300,28 +302,30 @@
if (reg != 0 && reg->signal_number_ == signal_number)
{
+#if defined(BOOST_ASIO_HAS_SIGNAL) || defined(BOOST_ASIO_HAS_SIGACTION)
// Set signal handler back to the default if we're the last.
if (state->registration_count_[signal_number] == 1)
{
-#if defined(BOOST_ASIO_HAS_SIGACTION)
+# if defined(BOOST_ASIO_HAS_SIGACTION)
using namespace std; // For memset.
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_DFL;
if (::sigaction(signal_number, &sa, 0) == -1)
-#else // defined(BOOST_ASIO_HAS_SIGACTION)
+# else // defined(BOOST_ASIO_HAS_SIGACTION)
if (::signal(signal_number, SIG_DFL) == SIG_ERR)
-#endif // defined(BOOST_ASIO_HAS_SIGACTION)
+# endif // defined(BOOST_ASIO_HAS_SIGACTION)
{
-#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
ec = boost::asio::error::invalid_argument;
-#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
ec = boost::system::error_code(errno,
boost::asio::error::get_system_category());
-#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
return ec;
}
}
+#endif // defined(BOOST_ASIO_HAS_SIGNAL) || defined(BOOST_ASIO_HAS_SIGACTION)
// Remove the registration from the set.
*deletion_point = reg->next_in_set_;
@@ -352,28 +356,30 @@
while (registration* reg = impl.signals_)
{
+#if defined(BOOST_ASIO_HAS_SIGNAL) || defined(BOOST_ASIO_HAS_SIGACTION)
// Set signal handler back to the default if we're the last.
if (state->registration_count_[reg->signal_number_] == 1)
{
-#if defined(BOOST_ASIO_HAS_SIGACTION)
+# if defined(BOOST_ASIO_HAS_SIGACTION)
using namespace std; // For memset.
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_DFL;
if (::sigaction(reg->signal_number_, &sa, 0) == -1)
-#else // defined(BOOST_ASIO_HAS_SIGACTION)
+# else // defined(BOOST_ASIO_HAS_SIGACTION)
if (::signal(reg->signal_number_, SIG_DFL) == SIG_ERR)
-#endif // defined(BOOST_ASIO_HAS_SIGACTION)
+# endif // defined(BOOST_ASIO_HAS_SIGACTION)
{
-#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
ec = boost::asio::error::invalid_argument;
-#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
ec = boost::system::error_code(errno,
boost::asio::error::get_system_category());
-#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+# endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
return ec;
}
}
+#endif // defined(BOOST_ASIO_HAS_SIGNAL) || defined(BOOST_ASIO_HAS_SIGACTION)
// Remove the registration from the registration table.
if (registrations_[reg->signal_number_] == reg)
Modified: trunk/boost/asio/ip/address.hpp
==============================================================================
--- trunk/boost/asio/ip/address.hpp (original)
+++ trunk/boost/asio/ip/address.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -55,9 +55,19 @@
/// Copy constructor.
BOOST_ASIO_DECL address(const address& other);
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move constructor.
+ BOOST_ASIO_DECL address(address&& other);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// Assign from another address.
BOOST_ASIO_DECL address& operator=(const address& other);
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move-assign from another address.
+ BOOST_ASIO_DECL address& operator=(address&& other);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// Assign from an IPv4 address.
BOOST_ASIO_DECL address& operator=(
const boost::asio::ip::address_v4& ipv4_address);
Modified: trunk/boost/asio/ip/address_v4.hpp
==============================================================================
--- trunk/boost/asio/ip/address_v4.hpp (original)
+++ trunk/boost/asio/ip/address_v4.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -73,6 +73,14 @@
{
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move constructor.
+ address_v4(address_v4&& other)
+ : addr_(other.addr_)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// Assign from another address.
address_v4& operator=(const address_v4& other)
{
@@ -80,6 +88,15 @@
return *this;
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move-assign from another address.
+ address_v4& operator=(address_v4&& other)
+ {
+ addr_ = other.addr_;
+ return *this;
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// Get the address in bytes, in network byte order.
BOOST_ASIO_DECL bytes_type to_bytes() const;
Modified: trunk/boost/asio/ip/address_v6.hpp
==============================================================================
--- trunk/boost/asio/ip/address_v6.hpp (original)
+++ trunk/boost/asio/ip/address_v6.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -66,9 +66,19 @@
/// Copy constructor.
BOOST_ASIO_DECL address_v6(const address_v6& other);
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move constructor.
+ BOOST_ASIO_DECL address_v6(address_v6&& other);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// Assign from another address.
BOOST_ASIO_DECL address_v6& operator=(const address_v6& other);
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move-assign from another address.
+ BOOST_ASIO_DECL address_v6& operator=(address_v6&& other);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// The scope ID of the address.
/**
* Returns the scope ID associated with the IPv6 address.
Modified: trunk/boost/asio/ip/basic_endpoint.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_endpoint.hpp (original)
+++ trunk/boost/asio/ip/basic_endpoint.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -98,6 +98,14 @@
{
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move constructor.
+ basic_endpoint(basic_endpoint&& other)
+ : impl_(other.impl_)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// Assign from another endpoint.
basic_endpoint& operator=(const basic_endpoint& other)
{
@@ -105,6 +113,15 @@
return *this;
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move-assign from another endpoint.
+ basic_endpoint& operator=(basic_endpoint&& other)
+ {
+ impl_ = other.impl_;
+ return *this;
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// The protocol associated with the endpoint.
protocol_type protocol() const
{
Modified: trunk/boost/asio/ip/impl/address.ipp
==============================================================================
--- trunk/boost/asio/ip/impl/address.ipp (original)
+++ trunk/boost/asio/ip/impl/address.ipp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -57,6 +57,15 @@
{
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+address::address(address&& other)
+ : type_(other.type_),
+ ipv4_address_(other.ipv4_address_),
+ ipv6_address_(other.ipv6_address_)
+{
+}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
address& address::operator=(const address& other)
{
type_ = other.type_;
@@ -65,6 +74,16 @@
return *this;
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+address& address::operator=(address&& other)
+{
+ type_ = other.type_;
+ ipv4_address_ = other.ipv4_address_;
+ ipv6_address_ = other.ipv6_address_;
+ return *this;
+}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
address& address::operator=(const boost::asio::ip::address_v4& ipv4_address)
{
type_ = ipv4;
Modified: trunk/boost/asio/ip/impl/address_v6.ipp
==============================================================================
--- trunk/boost/asio/ip/impl/address_v6.ipp (original)
+++ trunk/boost/asio/ip/impl/address_v6.ipp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -62,6 +62,14 @@
{
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+address_v6::address_v6(address_v6&& other)
+ : addr_(other.addr_),
+ scope_id_(other.scope_id_)
+{
+}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
address_v6& address_v6::operator=(const address_v6& other)
{
addr_ = other.addr_;
@@ -69,6 +77,15 @@
return *this;
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+address_v6& address_v6::operator=(address_v6&& other)
+{
+ addr_ = other.addr_;
+ scope_id_ = other.scope_id_;
+ return *this;
+}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
address_v6::bytes_type address_v6::to_bytes() const
{
using namespace std; // For memcpy.
Modified: trunk/boost/asio/local/basic_endpoint.hpp
==============================================================================
--- trunk/boost/asio/local/basic_endpoint.hpp (original)
+++ trunk/boost/asio/local/basic_endpoint.hpp 2011-05-17 17:46:54 EDT (Tue, 17 May 2011)
@@ -83,6 +83,14 @@
{
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move constructor.
+ basic_endpoint(basic_endpoint&& other)
+ : impl_(other.impl_)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// Assign from another endpoint.
basic_endpoint& operator=(const basic_endpoint& other)
{
@@ -90,6 +98,15 @@
return *this;
}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move-assign from another endpoint.
+ basic_endpoint& operator=(basic_endpoint&& other)
+ {
+ impl_ = other.impl_;
+ return *this;
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
/// The protocol associated with the endpoint.
protocol_type protocol() const
{
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