11 #ifndef ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP 12 #define ASIO_DETAIL_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) 43 class win_iocp_io_service
51 size_t concurrency_hint = 0);
83 return ::InterlockedExchangeAdd(&stopped_, 0) != 0;
89 ::InterlockedExchange(&stopped_, 0);
95 ::InterlockedIncrement(&outstanding_work_);
101 if (::InterlockedDecrement(&outstanding_work_) == 0)
108 return thread_call_stack::contains(
this) != 0;
112 template <
typename Handler>
113 void dispatch(Handler& handler);
116 template <
typename Handler>
117 void post(Handler& handler);
121 void post_immediate_completion(win_iocp_operation* op,
bool)
124 post_deferred_completion(op);
129 ASIO_DECL void post_deferred_completion(win_iocp_operation* op);
133 ASIO_DECL void post_deferred_completions(
134 op_queue<win_iocp_operation>& ops);
139 void post_private_immediate_completion(win_iocp_operation* op)
141 post_immediate_completion(op,
false);
147 void post_private_deferred_completion(win_iocp_operation* op)
149 post_deferred_completion(op);
154 ASIO_DECL void abandon_operations(op_queue<operation>& ops);
159 ASIO_DECL void on_pending(win_iocp_operation* op);
164 ASIO_DECL void on_completion(win_iocp_operation* op,
165 DWORD last_error = 0, DWORD bytes_transferred = 0);
170 ASIO_DECL void on_completion(win_iocp_operation* op,
174 template <
typename Time_Traits>
175 void add_timer_queue(timer_queue<Time_Traits>& timer_queue);
178 template <
typename Time_Traits>
179 void remove_timer_queue(timer_queue<Time_Traits>& timer_queue);
183 template <
typename Time_Traits>
184 void schedule_timer(timer_queue<Time_Traits>& queue,
185 const typename Time_Traits::time_type& time,
186 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op);
190 template <
typename Time_Traits>
191 std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
192 typename timer_queue<Time_Traits>::per_timer_data& timer,
193 std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
196 #if defined(WINVER) && (WINVER < 0x0500) 197 typedef DWORD dword_ptr_t;
198 typedef ULONG ulong_ptr_t;
199 #else // defined(WINVER) && (WINVER < 0x0500) 200 typedef DWORD_PTR dword_ptr_t;
201 typedef ULONG_PTR ulong_ptr_t;
202 #endif // defined(WINVER) && (WINVER < 0x0500) 210 ASIO_DECL static DWORD get_gqcs_timeout();
213 ASIO_DECL void do_add_timer_queue(timer_queue_base& queue);
216 ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue);
222 struct work_finished_on_block_exit;
228 auto_handle() : handle(0) {}
229 ~auto_handle() {
if (handle) ::CloseHandle(handle); }
236 long outstanding_work_;
239 mutable long stopped_;
244 long stop_event_posted_;
255 default_gqcs_timeout = 500,
258 max_timeout_msec = 5 * 60 * 1000,
261 max_timeout_usec = max_timeout_msec * 1000,
265 wake_for_dispatch = 1,
270 overlapped_contains_result = 2
274 const DWORD gqcs_timeout_;
277 struct timer_thread_function;
278 friend struct timer_thread_function;
281 scoped_ptr<thread> timer_thread_;
284 auto_handle waitable_timer_;
287 long dispatch_required_;
290 mutex dispatch_mutex_;
293 timer_queue_set timer_queues_;
296 op_queue<win_iocp_operation> completed_ops_;
299 typedef call_stack<win_iocp_io_service,
300 win_iocp_thread_info> thread_call_stack;
309 #if defined(ASIO_HEADER_ONLY) 311 #endif // defined(ASIO_HEADER_ONLY) 313 #endif // defined(ASIO_HAS_IOCP) 315 #endif // ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP
Provides core I/O functionality.
Class to represent an error code value.