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