mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
adds std/boost::ref as needed for non-const references passed to make_shared
required for boost::make_shared to work without rvalue references.
This commit is contained in:
@@ -39,8 +39,11 @@
|
||||
#else
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace websocketpp {
|
||||
namespace lib {
|
||||
|
||||
@@ -50,6 +53,13 @@ namespace lib {
|
||||
using std::ref;
|
||||
namespace placeholders = std::placeholders;
|
||||
|
||||
// There are some cases where a C++11 compiler balks at using std::ref
|
||||
// but a C++03 compiler using boost function requires boost::ref. As such
|
||||
// lib::ref is not useful in these cases. Instead this macro allows the use
|
||||
// of boost::ref in the case of a boost compile or no reference wrapper at
|
||||
// all in the case of a C++11 compile
|
||||
#define _WEBSOCKETPP_REF(x) x
|
||||
|
||||
template <typename T>
|
||||
void clear_function(T & x) {
|
||||
x = nullptr;
|
||||
@@ -64,6 +74,9 @@ namespace lib {
|
||||
using ::_2;
|
||||
}
|
||||
|
||||
// See above definition for more details on what this is and why it exists
|
||||
#define _WEBSOCKETPP_REF(x) boost::ref(x)
|
||||
|
||||
template <typename T>
|
||||
void clear_function(T & x) {
|
||||
x.clear();
|
||||
|
||||
@@ -1980,7 +1980,7 @@ connection<config>::get_processor(int version) const {
|
||||
transport_con_type::is_secure(),
|
||||
m_is_server,
|
||||
m_msg_manager,
|
||||
m_rng
|
||||
lib::ref(m_rng)
|
||||
);
|
||||
break;
|
||||
case 8:
|
||||
@@ -1988,7 +1988,7 @@ connection<config>::get_processor(int version) const {
|
||||
transport_con_type::is_secure(),
|
||||
m_is_server,
|
||||
m_msg_manager,
|
||||
m_rng
|
||||
lib::ref(m_rng)
|
||||
);
|
||||
break;
|
||||
case 13:
|
||||
@@ -1996,7 +1996,7 @@ connection<config>::get_processor(int version) const {
|
||||
transport_con_type::is_secure(),
|
||||
m_is_server,
|
||||
m_msg_manager,
|
||||
m_rng
|
||||
lib::ref(m_rng)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -43,7 +43,7 @@ endpoint<connection,config>::create_connection() {
|
||||
//scoped_lock_type guard(m_mutex);
|
||||
// Create a connection on the heap and manage it using a shared pointer
|
||||
connection_ptr con = lib::make_shared<connection_type>(m_is_server,
|
||||
m_user_agent, m_alog, m_elog, m_rng);
|
||||
m_user_agent, lib::ref(m_alog), lib::ref(m_elog), lib::ref(m_rng));
|
||||
|
||||
connection_weak_ptr w(con);
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
*/
|
||||
timer_ptr set_timer(long duration, timer_handler callback) {
|
||||
timer_ptr new_timer = lib::make_shared<boost::asio::deadline_timer>(
|
||||
*m_io_service,
|
||||
lib::ref(*m_io_service),
|
||||
boost::posix_time::milliseconds(duration)
|
||||
);
|
||||
|
||||
@@ -417,7 +417,8 @@ protected:
|
||||
m_io_service = io_service;
|
||||
|
||||
if (config::enable_multithreading) {
|
||||
m_strand = lib::make_shared<boost::asio::strand>(*io_service);
|
||||
m_strand = lib::make_shared<boost::asio::strand>(
|
||||
lib::ref(*io_service));
|
||||
|
||||
m_async_read_handler = m_strand->wrap(lib::bind(
|
||||
&type::handle_async_read, get_shared(),lib::placeholders::_1,
|
||||
|
||||
@@ -176,7 +176,9 @@ public:
|
||||
|
||||
m_io_service = ptr;
|
||||
m_external_io_service = true;
|
||||
m_acceptor = lib::make_shared<boost::asio::ip::tcp::acceptor>(*m_io_service);
|
||||
m_acceptor = lib::make_shared<boost::asio::ip::tcp::acceptor>(
|
||||
lib::ref(*m_io_service));
|
||||
|
||||
m_state = READY;
|
||||
ec = lib::error_code();
|
||||
}
|
||||
@@ -287,11 +289,11 @@ public:
|
||||
m_listen_backlog = backlog;
|
||||
}
|
||||
|
||||
/// Sets whether or not to use the SO_REUSEADDR flag when opening a listening socket
|
||||
/// Sets whether to use the SO_REUSEADDR flag when opening listening sockets
|
||||
/**
|
||||
* Specifies whether or not to use the SO_REUSEADDR TCP socket option. What this flag
|
||||
* does depends on your operating system. Please consult operating system
|
||||
* documentation for more details.
|
||||
* Specifies whether or not to use the SO_REUSEADDR TCP socket option. What
|
||||
* this flag does depends on your operating system. Please consult operating
|
||||
* system documentation for more details.
|
||||
*
|
||||
* New values affect future calls to listen only.
|
||||
*
|
||||
@@ -597,7 +599,9 @@ public:
|
||||
* @since 0.3.0
|
||||
*/
|
||||
void start_perpetual() {
|
||||
m_work = lib::make_shared<boost::asio::io_service::work>(*m_io_service);
|
||||
m_work = lib::make_shared<boost::asio::io_service::work>(
|
||||
lib::ref(*m_io_service)
|
||||
);
|
||||
}
|
||||
|
||||
/// Clears the endpoint's perpetual flag, allowing it to exit when empty
|
||||
@@ -761,7 +765,8 @@ protected:
|
||||
|
||||
// Create a resolver
|
||||
if (!m_resolver) {
|
||||
m_resolver = lib::make_shared<boost::asio::ip::tcp::resolver>(*m_io_service);
|
||||
m_resolver = lib::make_shared<boost::asio::ip::tcp::resolver>(
|
||||
lib::ref(*m_io_service));
|
||||
}
|
||||
|
||||
std::string proxy = tcon->get_proxy();
|
||||
|
||||
@@ -164,7 +164,8 @@ protected:
|
||||
return socket::make_error_code(socket::error::invalid_state);
|
||||
}
|
||||
|
||||
m_socket = lib::make_shared<boost::asio::ip::tcp::socket>(*service);
|
||||
m_socket = lib::make_shared<boost::asio::ip::tcp::socket>(
|
||||
lib::ref(*service));
|
||||
|
||||
m_state = READY;
|
||||
|
||||
|
||||
@@ -193,7 +193,8 @@ protected:
|
||||
if (!m_context) {
|
||||
return socket::make_error_code(socket::error::invalid_tls_context);
|
||||
}
|
||||
m_socket = lib::make_shared<socket_type>(*service,*m_context);
|
||||
m_socket = lib::make_shared<socket_type>(
|
||||
_WEBSOCKETPP_REF(*service),lib::ref(*m_context));
|
||||
|
||||
m_io_service = service;
|
||||
m_strand = strand;
|
||||
|
||||
Reference in New Issue
Block a user