File indexing completed on 2025-01-18 09:28:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_IMPL_WINRT_TIMER_SCHEDULER_HPP
0012 #define BOOST_ASIO_DETAIL_IMPL_WINRT_TIMER_SCHEDULER_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
0021
0022 #include <boost/asio/detail/push_options.hpp>
0023
0024 namespace boost {
0025 namespace asio {
0026 namespace detail {
0027
0028 template <typename Time_Traits>
0029 void winrt_timer_scheduler::add_timer_queue(timer_queue<Time_Traits>& queue)
0030 {
0031 do_add_timer_queue(queue);
0032 }
0033
0034
0035 template <typename Time_Traits>
0036 void winrt_timer_scheduler::remove_timer_queue(timer_queue<Time_Traits>& queue)
0037 {
0038 do_remove_timer_queue(queue);
0039 }
0040
0041 template <typename Time_Traits>
0042 void winrt_timer_scheduler::schedule_timer(timer_queue<Time_Traits>& queue,
0043 const typename Time_Traits::time_type& time,
0044 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
0045 {
0046 boost::asio::detail::mutex::scoped_lock lock(mutex_);
0047
0048 if (shutdown_)
0049 {
0050 scheduler_.post_immediate_completion(op, false);
0051 return;
0052 }
0053
0054 bool earliest = queue.enqueue_timer(time, timer, op);
0055 scheduler_.work_started();
0056 if (earliest)
0057 event_.signal(lock);
0058 }
0059
0060 template <typename Time_Traits>
0061 std::size_t winrt_timer_scheduler::cancel_timer(timer_queue<Time_Traits>& queue,
0062 typename timer_queue<Time_Traits>::per_timer_data& timer,
0063 std::size_t max_cancelled)
0064 {
0065 boost::asio::detail::mutex::scoped_lock lock(mutex_);
0066 op_queue<operation> ops;
0067 std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
0068 lock.unlock();
0069 scheduler_.post_deferred_completions(ops);
0070 return n;
0071 }
0072
0073 template <typename Time_Traits>
0074 void winrt_timer_scheduler::move_timer(timer_queue<Time_Traits>& queue,
0075 typename timer_queue<Time_Traits>::per_timer_data& to,
0076 typename timer_queue<Time_Traits>::per_timer_data& from)
0077 {
0078 boost::asio::detail::mutex::scoped_lock lock(mutex_);
0079 op_queue<operation> ops;
0080 queue.cancel_timer(to, ops);
0081 queue.move_timer(to, from);
0082 lock.unlock();
0083 scheduler_.post_deferred_completions(ops);
0084 }
0085
0086 }
0087 }
0088 }
0089
0090 #include <boost/asio/detail/pop_options.hpp>
0091
0092 #endif
0093
0094 #endif