Disable asio::executor if ASIO_NO_TS_EXECUTORS is defined.

This commit is contained in:
Christopher Kohlhoff 2020-06-21 10:39:12 +10:00
parent 390673c322
commit e0a3173e51
6 changed files with 33 additions and 14 deletions

View File

@ -16,6 +16,9 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#if !defined(ASIO_NO_TS_EXECUTORS)
#include <typeinfo>
#include "asio/detail/cstddef.hpp"
#include "asio/detail/executor_function.hpp"
@ -339,4 +342,6 @@ ASIO_USES_ALLOCATOR(asio::executor)
# include "asio/impl/executor.ipp"
#endif // defined(ASIO_HEADER_ONLY)
#endif // !defined(ASIO_NO_TS_EXECUTORS)
#endif // ASIO_EXECUTOR_HPP

View File

@ -16,6 +16,9 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#if !defined(ASIO_NO_TS_EXECUTORS)
#include "asio/detail/atomic_count.hpp"
#include "asio/detail/global.hpp"
#include "asio/detail/memory.hpp"
@ -293,4 +296,6 @@ const Executor* executor::target() const ASIO_NOEXCEPT
#include "asio/detail/pop_options.hpp"
#endif // !defined(ASIO_NO_TS_EXECUTORS)
#endif // ASIO_IMPL_EXECUTOR_HPP

View File

@ -16,6 +16,9 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#if !defined(ASIO_NO_TS_EXECUTORS)
#include "asio/executor.hpp"
#include "asio/detail/push_options.hpp"
@ -35,4 +38,6 @@ const char* bad_executor::what() const ASIO_NOEXCEPT_OR_NOTHROW
#include "asio/detail/pop_options.hpp"
#endif // !defined(ASIO_NO_TS_EXECUTORS)
#endif // ASIO_IMPL_EXECUTOR_IPP

View File

@ -83,7 +83,7 @@ class connection
public:
typedef boost::shared_ptr<connection> pointer;
static pointer create(const asio::executor& ex)
static pointer create(const asio::any_io_executor& ex)
{
return pointer(new connection(ex));
}
@ -102,7 +102,7 @@ public:
}
private:
connection(const asio::executor& ex)
connection(const asio::any_io_executor& ex)
: socket_(ex),
session_impl_(socket_),
read_in_progress_(false),

View File

@ -1,5 +1,5 @@
#include <asio/any_io_executor.hpp>
#include <asio/defer.hpp>
#include <asio/executor.hpp>
#include <asio/post.hpp>
#include <asio/strand.hpp>
#include <asio/system_executor.hpp>
@ -10,8 +10,8 @@
#include <typeinfo>
#include <vector>
using asio::any_io_executor;
using asio::defer;
using asio::executor;
using asio::post;
using asio::strand;
using asio::system_executor;
@ -106,7 +106,7 @@ public:
protected:
// Construct the actor to use the specified executor for all message handlers.
actor(executor e)
actor(any_io_executor e)
: executor_(std::move(e))
{
}
@ -124,7 +124,7 @@ protected:
template <class Actor, class Message>
void deregister_handler(void (Actor::* mf)(Message, actor_address))
{
const std::type_info& id = typeid(message_handler<Message>);
const std::type_info& id = typeid(Message);
for (auto iter = handlers_.begin(); iter != handlers_.end(); ++iter)
{
if ((*iter)->message_id() == id)
@ -171,7 +171,7 @@ private:
// All messages associated with a single actor object should be processed
// non-concurrently. We use a strand to ensure non-concurrent execution even
// if the underlying executor may use multiple threads.
strand<executor> executor_;
strand<any_io_executor> executor_;
std::vector<std::shared_ptr<message_handler_base>> handlers_;
};
@ -221,7 +221,7 @@ using asio::thread_pool;
class member : public actor
{
public:
explicit member(executor e)
explicit member(any_io_executor e)
: actor(std::move(e))
{
register_handler(&member::init_handler);

View File

@ -1,4 +1,8 @@
#include <asio/ts/executor.hpp>
#include <asio/any_io_executor.hpp>
#include <asio/defer.hpp>
#include <asio/post.hpp>
#include <asio/strand.hpp>
#include <asio/system_executor.hpp>
#include <condition_variable>
#include <deque>
#include <memory>
@ -6,8 +10,8 @@
#include <typeinfo>
#include <vector>
using asio::any_io_executor;
using asio::defer;
using asio::executor;
using asio::post;
using asio::strand;
using asio::system_executor;
@ -94,7 +98,7 @@ public:
{
// Execute the message handler in the context of the target's executor.
post(to->executor_,
[=, msg=std::move(msg)]
[=, msg=std::move(msg)]() mutable
{
to->call_handler(std::move(msg), from);
});
@ -102,7 +106,7 @@ public:
protected:
// Construct the actor to use the specified executor for all message handlers.
actor(executor e)
actor(any_io_executor e)
: executor_(std::move(e))
{
}
@ -166,7 +170,7 @@ private:
// All messages associated with a single actor object should be processed
// non-concurrently. We use a strand to ensure non-concurrent execution even
// if the underlying executor may use multiple threads.
strand<executor> executor_;
strand<any_io_executor> executor_;
std::vector<std::shared_ptr<message_handler_base>> handlers_;
};
@ -216,7 +220,7 @@ using asio::thread_pool;
class member : public actor
{
public:
explicit member(executor e)
explicit member(any_io_executor e)
: actor(std::move(e))
{
register_handler(&member::init_handler);