Chris@102
|
1 // thread_pool.hpp --------------------------------------------------------------//
|
Chris@102
|
2
|
Chris@102
|
3 // Copyright 2013 Andrey Semashev
|
Chris@102
|
4
|
Chris@102
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@102
|
6 // See http://www.boost.org/LICENSE_1_0.txt
|
Chris@102
|
7
|
Chris@102
|
8
|
Chris@102
|
9 #ifndef BOOST_DETAIL_WINAPI_THREAD_POOL_HPP
|
Chris@102
|
10 #define BOOST_DETAIL_WINAPI_THREAD_POOL_HPP
|
Chris@102
|
11
|
Chris@102
|
12 #include <boost/detail/winapi/basic_types.hpp>
|
Chris@102
|
13
|
Chris@102
|
14 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@102
|
15 #pragma once
|
Chris@102
|
16 #endif
|
Chris@102
|
17
|
Chris@102
|
18 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K
|
Chris@102
|
19
|
Chris@102
|
20 namespace boost
|
Chris@102
|
21 {
|
Chris@102
|
22 namespace detail
|
Chris@102
|
23 {
|
Chris@102
|
24 namespace winapi
|
Chris@102
|
25 {
|
Chris@102
|
26 #if defined( BOOST_USE_WINDOWS_H )
|
Chris@102
|
27
|
Chris@102
|
28 typedef ::WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACKFUNC_;
|
Chris@102
|
29 typedef ::WAITORTIMERCALLBACK WAITORTIMERCALLBACK_;
|
Chris@102
|
30
|
Chris@102
|
31 using ::RegisterWaitForSingleObject;
|
Chris@102
|
32 using ::UnregisterWait;
|
Chris@102
|
33 using ::UnregisterWaitEx;
|
Chris@102
|
34
|
Chris@102
|
35 const ULONG_ wt_execute_default = WT_EXECUTEDEFAULT;
|
Chris@102
|
36 const ULONG_ wt_execute_in_io_thread = WT_EXECUTEINIOTHREAD;
|
Chris@102
|
37 const ULONG_ wt_execute_in_ui_thread = WT_EXECUTEINUITHREAD;
|
Chris@102
|
38 const ULONG_ wt_execute_in_wait_thread = WT_EXECUTEINWAITTHREAD;
|
Chris@102
|
39 const ULONG_ wt_execute_only_once = WT_EXECUTEONLYONCE;
|
Chris@102
|
40 const ULONG_ wt_execute_in_timer_thread = WT_EXECUTEINTIMERTHREAD;
|
Chris@102
|
41 const ULONG_ wt_execute_long_function = WT_EXECUTELONGFUNCTION;
|
Chris@102
|
42 const ULONG_ wt_execute_in_persistent_io_thread = WT_EXECUTEINPERSISTENTIOTHREAD;
|
Chris@102
|
43 const ULONG_ wt_execute_in_persistent_thread = WT_EXECUTEINPERSISTENTTHREAD;
|
Chris@102
|
44 const ULONG_ wt_transfer_impersonation = WT_TRANSFER_IMPERSONATION;
|
Chris@102
|
45
|
Chris@102
|
46 inline ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit)
|
Chris@102
|
47 {
|
Chris@102
|
48 return WT_SET_MAX_THREADPOOL_THREADS(flags, limit);
|
Chris@102
|
49 }
|
Chris@102
|
50
|
Chris@102
|
51 #else
|
Chris@102
|
52
|
Chris@102
|
53 extern "C" {
|
Chris@102
|
54
|
Chris@102
|
55 typedef void (NTAPI* WAITORTIMERCALLBACKFUNC_) (PVOID_, BOOLEAN_);
|
Chris@102
|
56 typedef WAITORTIMERCALLBACKFUNC_ WAITORTIMERCALLBACK_;
|
Chris@102
|
57
|
Chris@102
|
58 __declspec(dllimport) BOOL_ WINAPI RegisterWaitForSingleObject
|
Chris@102
|
59 (
|
Chris@102
|
60 HANDLE_* phNewWaitObject,
|
Chris@102
|
61 HANDLE_ hObject,
|
Chris@102
|
62 WAITORTIMERCALLBACK_ Callback,
|
Chris@102
|
63 PVOID_ Context,
|
Chris@102
|
64 ULONG_ dwMilliseconds,
|
Chris@102
|
65 ULONG_ dwFlags
|
Chris@102
|
66 );
|
Chris@102
|
67
|
Chris@102
|
68 __declspec(dllimport) BOOL_ WINAPI UnregisterWait(HANDLE_ WaitHandle);
|
Chris@102
|
69 __declspec(dllimport) BOOL_ WINAPI UnregisterWaitEx(HANDLE_ WaitHandle, HANDLE_ CompletionEvent);
|
Chris@102
|
70
|
Chris@102
|
71 } // extern "C"
|
Chris@102
|
72
|
Chris@102
|
73 const ULONG_ wt_execute_default = 0x00000000;
|
Chris@102
|
74 const ULONG_ wt_execute_in_io_thread = 0x00000001;
|
Chris@102
|
75 const ULONG_ wt_execute_in_ui_thread = 0x00000002;
|
Chris@102
|
76 const ULONG_ wt_execute_in_wait_thread = 0x00000004;
|
Chris@102
|
77 const ULONG_ wt_execute_only_once = 0x00000008;
|
Chris@102
|
78 const ULONG_ wt_execute_in_timer_thread = 0x00000020;
|
Chris@102
|
79 const ULONG_ wt_execute_long_function = 0x00000010;
|
Chris@102
|
80 const ULONG_ wt_execute_in_persistent_io_thread = 0x00000040;
|
Chris@102
|
81 const ULONG_ wt_execute_in_persistent_thread = 0x00000080;
|
Chris@102
|
82 const ULONG_ wt_transfer_impersonation = 0x00000100;
|
Chris@102
|
83
|
Chris@102
|
84 inline ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit)
|
Chris@102
|
85 {
|
Chris@102
|
86 return flags | (limit << 16);
|
Chris@102
|
87 }
|
Chris@102
|
88
|
Chris@102
|
89 #endif
|
Chris@102
|
90 }
|
Chris@102
|
91 }
|
Chris@102
|
92 }
|
Chris@102
|
93
|
Chris@102
|
94 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K
|
Chris@102
|
95
|
Chris@102
|
96 #endif // BOOST_DETAIL_WINAPI_THREAD_POOL_HPP
|