]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/include/boost/asio/detail/impl/winrt_timer_scheduler.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / detail / impl / winrt_timer_scheduler.hpp
CommitLineData
7c673cae
FG
1//
2// detail/impl/winrt_timer_scheduler.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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 {
50 io_service_.post_immediate_completion(op, false);
51 return;
52 }
53
54 bool earliest = queue.enqueue_timer(time, timer, op);
55 io_service_.work_started();
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();
69 io_service_.post_deferred_completions(ops);
70 return n;
71}
72
73} // namespace detail
74} // namespace asio
75} // namespace boost
76
77#include <boost/asio/detail/pop_options.hpp>
78
79#endif // defined(BOOST_ASIO_WINDOWS_RUNTIME)
80
81#endif // BOOST_ASIO_DETAIL_IMPL_WINRT_TIMER_SCHEDULER_HPP