]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/detail/impl/kqueue_reactor.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / asio / detail / impl / kqueue_reactor.hpp
CommitLineData
7c673cae
FG
1//
2// detail/impl/kqueue_reactor.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
92f5a8d4 5// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7c673cae
FG
6// Copyright (c) 2005 Stefan Arentz (stefan at soze dot com)
7//
8// Distributed under the Boost Software License, Version 1.0. (See accompanying
9// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10//
11
12#ifndef BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_HPP
13#define BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_HPP
14
15#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16# pragma once
17#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
19#include <boost/asio/detail/config.hpp>
20
21#if defined(BOOST_ASIO_HAS_KQUEUE)
22
23#include <boost/asio/detail/push_options.hpp>
24
25namespace boost {
26namespace asio {
27namespace detail {
28
29template <typename Time_Traits>
30void kqueue_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
31{
32 do_add_timer_queue(queue);
33}
34
35// Remove a timer queue from the reactor.
36template <typename Time_Traits>
37void kqueue_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue)
38{
39 do_remove_timer_queue(queue);
40}
41
42template <typename Time_Traits>
43void kqueue_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
44 const typename Time_Traits::time_type& time,
45 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
46{
b32b8144 47 mutex::scoped_lock lock(mutex_);
7c673cae
FG
48
49 if (shutdown_)
50 {
b32b8144 51 scheduler_.post_immediate_completion(op, false);
7c673cae
FG
52 return;
53 }
54
55 bool earliest = queue.enqueue_timer(time, timer, op);
b32b8144 56 scheduler_.work_started();
7c673cae
FG
57 if (earliest)
58 interrupt();
59}
60
61template <typename Time_Traits>
62std::size_t kqueue_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
63 typename timer_queue<Time_Traits>::per_timer_data& timer,
64 std::size_t max_cancelled)
65{
b32b8144 66 mutex::scoped_lock lock(mutex_);
7c673cae
FG
67 op_queue<operation> ops;
68 std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
69 lock.unlock();
b32b8144 70 scheduler_.post_deferred_completions(ops);
7c673cae
FG
71 return n;
72}
73
b32b8144
FG
74template <typename Time_Traits>
75void kqueue_reactor::move_timer(timer_queue<Time_Traits>& queue,
76 typename timer_queue<Time_Traits>::per_timer_data& target,
77 typename timer_queue<Time_Traits>::per_timer_data& source)
78{
79 mutex::scoped_lock lock(mutex_);
80 op_queue<operation> ops;
81 queue.cancel_timer(target, ops);
82 queue.move_timer(target, source);
83 lock.unlock();
84 scheduler_.post_deferred_completions(ops);
85}
86
7c673cae
FG
87} // namespace detail
88} // namespace asio
89} // namespace boost
90
91#include <boost/asio/detail/pop_options.hpp>
92
93#endif // defined(BOOST_ASIO_HAS_KQUEUE)
94
95#endif // BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_HPP