diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:11:01 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:11:01 +0900 |
commit | 3fdc3e5ee96dca5b11d1694975a65200787eab86 (patch) | |
tree | 5c1733853892b8397d67706fa453a9bd978d2102 /boost/asio/detail/kqueue_reactor.hpp | |
parent | 88e602c57797660ebe0f9e15dbd64c1ff16dead3 (diff) | |
download | boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.gz boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.bz2 boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.zip |
Imported Upstream version 1.66.0upstream/1.66.0
Diffstat (limited to 'boost/asio/detail/kqueue_reactor.hpp')
-rw-r--r-- | boost/asio/detail/kqueue_reactor.hpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/boost/asio/detail/kqueue_reactor.hpp b/boost/asio/detail/kqueue_reactor.hpp index c6182b4d55..492b7ff016 100644 --- a/boost/asio/detail/kqueue_reactor.hpp +++ b/boost/asio/detail/kqueue_reactor.hpp @@ -35,7 +35,7 @@ #include <boost/asio/detail/timer_queue_set.hpp> #include <boost/asio/detail/wait_op.hpp> #include <boost/asio/error.hpp> -#include <boost/asio/io_service.hpp> +#include <boost/asio/execution_context.hpp> // Older versions of Mac OS X may not define EV_OOBAND. #if !defined(EV_OOBAND) @@ -48,9 +48,15 @@ namespace boost { namespace asio { namespace detail { +class scheduler; + class kqueue_reactor - : public boost::asio::detail::service_base<kqueue_reactor> + : public execution_context_service_base<kqueue_reactor> { +private: + // The mutex type used by this reactor. + typedef conditionally_enabled_mutex mutex; + public: enum op_types { read_op = 0, write_op = 1, connect_op = 1, except_op = 2, max_ops = 3 }; @@ -58,6 +64,8 @@ public: // Per-descriptor queues. struct descriptor_state { + descriptor_state(bool locking) : mutex_(locking) {} + friend class kqueue_reactor; friend class object_pool_access; @@ -75,17 +83,17 @@ public: typedef descriptor_state* per_descriptor_data; // Constructor. - BOOST_ASIO_DECL kqueue_reactor(boost::asio::io_service& io_service); + BOOST_ASIO_DECL kqueue_reactor(boost::asio::execution_context& ctx); // Destructor. BOOST_ASIO_DECL ~kqueue_reactor(); // Destroy all user-defined handler objects owned by the service. - BOOST_ASIO_DECL void shutdown_service(); + BOOST_ASIO_DECL void shutdown(); // Recreate internal descriptors following a fork. - BOOST_ASIO_DECL void fork_service( - boost::asio::io_service::fork_event fork_ev); + BOOST_ASIO_DECL void notify_fork( + boost::asio::execution_context::fork_event fork_ev); // Initialise the task. BOOST_ASIO_DECL void init_task(); @@ -109,7 +117,7 @@ public: // Post a reactor operation for immediate completion. void post_immediate_completion(reactor_op* op, bool is_continuation) { - io_service_.post_immediate_completion(op, is_continuation); + scheduler_.post_immediate_completion(op, is_continuation); } // Start a new operation. The reactor operation will be performed when the @@ -163,8 +171,14 @@ public: typename timer_queue<Time_Traits>::per_timer_data& timer, std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)()); + // Move the timer operations associated with the given timer. + template <typename Time_Traits> + void move_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& target, + typename timer_queue<Time_Traits>::per_timer_data& source); + // Run the kqueue loop. - BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops); + BOOST_ASIO_DECL void run(long usec, op_queue<operation>& ops); // Interrupt the kqueue loop. BOOST_ASIO_DECL void interrupt(); @@ -187,10 +201,10 @@ private: BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue); // Get the timeout value for the kevent call. - BOOST_ASIO_DECL timespec* get_timeout(timespec& ts); + BOOST_ASIO_DECL timespec* get_timeout(long usec, timespec& ts); - // The io_service implementation used to post completions. - io_service_impl& io_service_; + // The scheduler used to post completions. + scheduler& scheduler_; // Mutex to protect access to internal data. mutex mutex_; |