diff options
Diffstat (limited to 'src/common/Asio')
-rw-r--r-- | src/common/Asio/IoContext.h | 17 | ||||
-rw-r--r-- | src/common/Asio/Strand.h | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/common/Asio/IoContext.h b/src/common/Asio/IoContext.h index b26de194b5c..4b469d3baa2 100644 --- a/src/common/Asio/IoContext.h +++ b/src/common/Asio/IoContext.h @@ -18,6 +18,7 @@ #ifndef IoContext_h__ #define IoContext_h__ +#include <boost/asio/bind_executor.hpp> #include <boost/asio/io_context.hpp> #include <boost/asio/post.hpp> @@ -28,6 +29,8 @@ namespace Trinity class IoContext { public: + using Executor = boost::asio::io_context::executor_type; + IoContext() : _impl() { } explicit IoContext(int concurrency_hint) : _impl(concurrency_hint) { } @@ -35,9 +38,13 @@ namespace Trinity operator boost::asio::io_context const&() const { return _impl; } std::size_t run() { return _impl.run(); } + std::size_t poll() { return _impl.poll(); } void stop() { _impl.stop(); } - boost::asio::io_context::executor_type get_executor() noexcept { return _impl.get_executor(); } + bool stopped() const { return _impl.stopped(); } + void restart() { return _impl.restart(); } + + Executor get_executor() noexcept { return _impl.get_executor(); } private: boost::asio::io_context _impl; @@ -50,6 +57,14 @@ namespace Trinity } template<typename T> + inline decltype(auto) post(boost::asio::io_context::executor_type& executor, T&& t) + { + return boost::asio::post(executor, std::forward<T>(t)); + } + + using boost::asio::bind_executor; + + template<typename T> inline decltype(auto) get_io_context(T&& ioObject) { return ioObject.get_executor().context(); diff --git a/src/common/Asio/Strand.h b/src/common/Asio/Strand.h index 942ddf55cd4..5228a30103b 100644 --- a/src/common/Asio/Strand.h +++ b/src/common/Asio/Strand.h @@ -19,7 +19,6 @@ #define Strand_h__ #include "IoContext.h" -#include <boost/asio/bind_executor.hpp> #include <boost/asio/strand.hpp> namespace Trinity |