]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | /* |
2 | * Copyright 2013 Andrey Semashev | |
3 | * | |
4 | * Distributed under the Boost Software License, Version 1.0. | |
5 | * See http://www.boost.org/LICENSE_1_0.txt | |
6 | */ | |
7c673cae | 7 | |
b32b8144 FG |
8 | #ifndef BOOST_WINAPI_THREAD_POOL_HPP_INCLUDED_ |
9 | #define BOOST_WINAPI_THREAD_POOL_HPP_INCLUDED_ | |
7c673cae | 10 | |
b32b8144 | 11 | #include <boost/winapi/config.hpp> |
7c673cae FG |
12 | |
13 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
14 | #pragma once | |
15 | #endif | |
16 | ||
17 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K | |
18 | ||
b32b8144 | 19 | #include <boost/winapi/basic_types.hpp> |
20effc67 | 20 | #include <boost/winapi/detail/header.hpp> |
7c673cae FG |
21 | |
22 | #if !defined( BOOST_USE_WINDOWS_H ) | |
23 | extern "C" { | |
b32b8144 | 24 | #if BOOST_WINAPI_PARTITION_DESKTOP |
92f5a8d4 | 25 | typedef boost::winapi::VOID_ (BOOST_WINAPI_NTAPI_CC *WAITORTIMERCALLBACKFUNC) |
b32b8144 | 26 | (boost::winapi::PVOID_, boost::winapi::BOOLEAN_); |
7c673cae FG |
27 | typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK; |
28 | ||
20effc67 | 29 | BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC |
7c673cae | 30 | RegisterWaitForSingleObject( |
b32b8144 FG |
31 | boost::winapi::PHANDLE_ phNewWaitObject, |
32 | boost::winapi::HANDLE_ hObject, | |
7c673cae | 33 | WAITORTIMERCALLBACK Callback, |
b32b8144 FG |
34 | boost::winapi::PVOID_ Context, |
35 | boost::winapi::ULONG_ dwMilliseconds, | |
36 | boost::winapi::ULONG_ dwFlags); | |
37 | #endif | |
38 | } // extern "C" | |
7c673cae FG |
39 | #endif |
40 | ||
41 | // MinGW is buggy - it is missing these function declarations for Win2000 | |
42 | #if !defined( BOOST_USE_WINDOWS_H ) || (defined(BOOST_WINAPI_IS_MINGW) && BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP) | |
43 | extern "C" { | |
b32b8144 | 44 | #if BOOST_WINAPI_PARTITION_DESKTOP |
20effc67 | 45 | BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC |
b32b8144 FG |
46 | UnregisterWait(boost::winapi::HANDLE_ WaitHandle); |
47 | #endif | |
7c673cae | 48 | |
b32b8144 | 49 | #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM |
20effc67 | 50 | BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC |
7c673cae | 51 | UnregisterWaitEx( |
b32b8144 FG |
52 | boost::winapi::HANDLE_ WaitHandle, |
53 | boost::winapi::HANDLE_ CompletionEvent); | |
54 | #endif | |
55 | } // extern "C" | |
7c673cae FG |
56 | #endif |
57 | ||
58 | namespace boost { | |
7c673cae FG |
59 | namespace winapi { |
60 | ||
b32b8144 | 61 | #if BOOST_WINAPI_PARTITION_DESKTOP |
7c673cae FG |
62 | typedef ::WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACKFUNC_; |
63 | typedef ::WAITORTIMERCALLBACK WAITORTIMERCALLBACK_; | |
64 | ||
65 | using ::RegisterWaitForSingleObject; | |
66 | using ::UnregisterWait; | |
b32b8144 | 67 | #endif |
7c673cae | 68 | |
b32b8144 FG |
69 | #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM |
70 | using ::UnregisterWaitEx; | |
71 | #endif | |
7c673cae FG |
72 | #if defined( BOOST_USE_WINDOWS_H ) |
73 | ||
92f5a8d4 TL |
74 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEDEFAULT_ = WT_EXECUTEDEFAULT; |
75 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINIOTHREAD_ = WT_EXECUTEINIOTHREAD; | |
7c673cae | 76 | #if defined( BOOST_WINAPI_IS_MINGW ) |
92f5a8d4 | 77 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002; |
7c673cae | 78 | #else |
92f5a8d4 | 79 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINUITHREAD_ = WT_EXECUTEINUITHREAD; |
7c673cae | 80 | #endif |
92f5a8d4 TL |
81 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINWAITTHREAD_ = WT_EXECUTEINWAITTHREAD; |
82 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEONLYONCE_ = WT_EXECUTEONLYONCE; | |
83 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINTIMERTHREAD_ = WT_EXECUTEINTIMERTHREAD; | |
84 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTELONGFUNCTION_ = WT_EXECUTELONGFUNCTION; | |
7c673cae | 85 | #if defined( BOOST_WINAPI_IS_MINGW ) |
92f5a8d4 | 86 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040; |
7c673cae | 87 | #else |
92f5a8d4 | 88 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = WT_EXECUTEINPERSISTENTIOTHREAD; |
7c673cae | 89 | #endif |
92f5a8d4 TL |
90 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = WT_EXECUTEINPERSISTENTTHREAD; |
91 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_TRANSFER_IMPERSONATION_ = WT_TRANSFER_IMPERSONATION; | |
7c673cae | 92 | |
7c673cae FG |
93 | #else // defined( BOOST_USE_WINDOWS_H ) |
94 | ||
92f5a8d4 TL |
95 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEDEFAULT_ = 0x00000000; |
96 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINIOTHREAD_ = 0x00000001; | |
97 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002; | |
98 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINWAITTHREAD_ = 0x00000004; | |
99 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEONLYONCE_ = 0x00000008; | |
100 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINTIMERTHREAD_ = 0x00000020; | |
101 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTELONGFUNCTION_ = 0x00000010; | |
102 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040; | |
103 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = 0x00000080; | |
104 | BOOST_CONSTEXPR_OR_CONST ULONG_ WT_TRANSFER_IMPERSONATION_ = 0x00000100; | |
7c673cae | 105 | |
b32b8144 FG |
106 | #endif // defined( BOOST_USE_WINDOWS_H ) |
107 | ||
108 | BOOST_FORCEINLINE BOOST_CONSTEXPR ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit) BOOST_NOEXCEPT | |
7c673cae | 109 | { |
b32b8144 FG |
110 | // Note: We don't use WT_SET_MAX_THREADPOOL_THREADS here because the way it's defined |
111 | // the function no longer meets C++11 constexpr requirements. | |
7c673cae FG |
112 | return flags | (limit << 16); |
113 | } | |
114 | ||
92f5a8d4 TL |
115 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_default = WT_EXECUTEDEFAULT_; |
116 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_in_io_thread = WT_EXECUTEINIOTHREAD_; | |
117 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_in_ui_thread = WT_EXECUTEINUITHREAD_; | |
118 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_in_wait_thread = WT_EXECUTEINWAITTHREAD_; | |
119 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_only_once = WT_EXECUTEONLYONCE_; | |
120 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_in_timer_thread = WT_EXECUTEINTIMERTHREAD_; | |
121 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_long_function = WT_EXECUTELONGFUNCTION_; | |
122 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_in_persistent_io_thread = WT_EXECUTEINPERSISTENTIOTHREAD_; | |
123 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_execute_in_persistent_thread = WT_EXECUTEINPERSISTENTTHREAD_; | |
124 | BOOST_CONSTEXPR_OR_CONST ULONG_ wt_transfer_impersonation = WT_TRANSFER_IMPERSONATION_; | |
7c673cae | 125 | |
7c673cae FG |
126 | } |
127 | } | |
128 | ||
20effc67 TL |
129 | #include <boost/winapi/detail/footer.hpp> |
130 | ||
7c673cae | 131 | #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K |
b32b8144 | 132 | #endif // BOOST_WINAPI_THREAD_POOL_HPP_INCLUDED_ |