11 #ifndef ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP 12 #define ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 20 #if defined(ASIO_HAS_IOCP) 33 template <
typename Handler>
34 void win_iocp_io_service::dispatch(Handler& handler)
36 if (thread_call_stack::contains(
this))
44 typedef completion_handler<Handler> op;
45 typename op::ptr p = { asio::detail::addressof(handler),
47 sizeof(op), handler), 0 };
48 p.p =
new (p.v) op(handler);
52 post_immediate_completion(p.p,
false);
57 template <
typename Handler>
58 void win_iocp_io_service::post(Handler& handler)
61 typedef completion_handler<Handler> op;
62 typename op::ptr p = { asio::detail::addressof(handler),
64 sizeof(op), handler), 0 };
65 p.p =
new (p.v) op(handler);
69 post_immediate_completion(p.p,
false);
73 template <
typename Time_Traits>
74 void win_iocp_io_service::add_timer_queue(
75 timer_queue<Time_Traits>& queue)
77 do_add_timer_queue(queue);
80 template <
typename Time_Traits>
81 void win_iocp_io_service::remove_timer_queue(
82 timer_queue<Time_Traits>& queue)
84 do_remove_timer_queue(queue);
87 template <
typename Time_Traits>
88 void win_iocp_io_service::schedule_timer(timer_queue<Time_Traits>& queue,
89 const typename Time_Traits::time_type& time,
90 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
93 if (::InterlockedExchangeAdd(&shutdown_, 0) != 0)
95 post_immediate_completion(op,
false);
101 bool earliest = queue.enqueue_timer(time, timer, op);
107 template <
typename Time_Traits>
108 std::size_t win_iocp_io_service::cancel_timer(timer_queue<Time_Traits>& queue,
109 typename timer_queue<Time_Traits>::per_timer_data& timer,
110 std::size_t max_cancelled)
113 if (::InterlockedExchangeAdd(&shutdown_, 0) != 0)
117 op_queue<win_iocp_operation> ops;
118 std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
119 post_deferred_completions(ops);
128 #endif // defined(ASIO_HAS_IOCP) 130 #endif // ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP
asio::basic_streambuf< Allocator > & b
null_fenced_block fenced_block
void invoke(Function &function, Context &context)
asio::detail::scoped_lock< null_mutex > scoped_lock
void * allocate(std::size_t s, Handler &h)
#define ASIO_HANDLER_CREATION(args)