2 * Copyright 2013 Andrey Semashev
4 * Distributed under the Boost Software License, Version 1.0.
5 * See http://www.boost.org/LICENSE_1_0.txt
8 #ifndef BOOST_WINAPI_THREAD_POOL_HPP_INCLUDED_
9 #define BOOST_WINAPI_THREAD_POOL_HPP_INCLUDED_
11 #include <boost/winapi/config.hpp>
13 #ifdef BOOST_HAS_PRAGMA_ONCE
17 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K
19 #include <boost/winapi/basic_types.hpp>
21 #if !defined( BOOST_USE_WINDOWS_H )
23 #if BOOST_WINAPI_PARTITION_DESKTOP
24 typedef boost::winapi::VOID_ (NTAPI *WAITORTIMERCALLBACKFUNC)
25 (boost::winapi::PVOID_, boost::winapi::BOOLEAN_);
26 typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK;
28 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
29 RegisterWaitForSingleObject(
30 boost::winapi::PHANDLE_ phNewWaitObject,
31 boost::winapi::HANDLE_ hObject,
32 WAITORTIMERCALLBACK Callback,
33 boost::winapi::PVOID_ Context,
34 boost::winapi::ULONG_ dwMilliseconds,
35 boost::winapi::ULONG_ dwFlags);
40 // MinGW is buggy - it is missing these function declarations for Win2000
41 #if !defined( BOOST_USE_WINDOWS_H ) || (defined(BOOST_WINAPI_IS_MINGW) && BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP)
43 #if BOOST_WINAPI_PARTITION_DESKTOP
44 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
45 UnregisterWait(boost::winapi::HANDLE_ WaitHandle);
48 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
49 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
51 boost::winapi::HANDLE_ WaitHandle,
52 boost::winapi::HANDLE_ CompletionEvent);
60 #if BOOST_WINAPI_PARTITION_DESKTOP
61 typedef ::WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACKFUNC_;
62 typedef ::WAITORTIMERCALLBACK WAITORTIMERCALLBACK_;
64 using ::RegisterWaitForSingleObject;
65 using ::UnregisterWait;
68 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
69 using ::UnregisterWaitEx;
71 #if defined( BOOST_USE_WINDOWS_H )
73 const ULONG_ WT_EXECUTEDEFAULT_ = WT_EXECUTEDEFAULT;
74 const ULONG_ WT_EXECUTEINIOTHREAD_ = WT_EXECUTEINIOTHREAD;
75 #if defined( BOOST_WINAPI_IS_MINGW )
76 const ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002;
78 const ULONG_ WT_EXECUTEINUITHREAD_ = WT_EXECUTEINUITHREAD;
80 const ULONG_ WT_EXECUTEINWAITTHREAD_ = WT_EXECUTEINWAITTHREAD;
81 const ULONG_ WT_EXECUTEONLYONCE_ = WT_EXECUTEONLYONCE;
82 const ULONG_ WT_EXECUTEINTIMERTHREAD_ = WT_EXECUTEINTIMERTHREAD;
83 const ULONG_ WT_EXECUTELONGFUNCTION_ = WT_EXECUTELONGFUNCTION;
84 #if defined( BOOST_WINAPI_IS_MINGW )
85 const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040;
87 const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = WT_EXECUTEINPERSISTENTIOTHREAD;
89 const ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = WT_EXECUTEINPERSISTENTTHREAD;
90 const ULONG_ WT_TRANSFER_IMPERSONATION_ = WT_TRANSFER_IMPERSONATION;
92 #else // defined( BOOST_USE_WINDOWS_H )
94 const ULONG_ WT_EXECUTEDEFAULT_ = 0x00000000;
95 const ULONG_ WT_EXECUTEINIOTHREAD_ = 0x00000001;
96 const ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002;
97 const ULONG_ WT_EXECUTEINWAITTHREAD_ = 0x00000004;
98 const ULONG_ WT_EXECUTEONLYONCE_ = 0x00000008;
99 const ULONG_ WT_EXECUTEINTIMERTHREAD_ = 0x00000020;
100 const ULONG_ WT_EXECUTELONGFUNCTION_ = 0x00000010;
101 const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040;
102 const ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = 0x00000080;
103 const ULONG_ WT_TRANSFER_IMPERSONATION_ = 0x00000100;
105 #endif // defined( BOOST_USE_WINDOWS_H )
107 BOOST_FORCEINLINE BOOST_CONSTEXPR ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit) BOOST_NOEXCEPT
109 // Note: We don't use WT_SET_MAX_THREADPOOL_THREADS here because the way it's defined
110 // the function no longer meets C++11 constexpr requirements.
111 return flags | (limit << 16);
114 const ULONG_ wt_execute_default = WT_EXECUTEDEFAULT_;
115 const ULONG_ wt_execute_in_io_thread = WT_EXECUTEINIOTHREAD_;
116 const ULONG_ wt_execute_in_ui_thread = WT_EXECUTEINUITHREAD_;
117 const ULONG_ wt_execute_in_wait_thread = WT_EXECUTEINWAITTHREAD_;
118 const ULONG_ wt_execute_only_once = WT_EXECUTEONLYONCE_;
119 const ULONG_ wt_execute_in_timer_thread = WT_EXECUTEINTIMERTHREAD_;
120 const ULONG_ wt_execute_long_function = WT_EXECUTELONGFUNCTION_;
121 const ULONG_ wt_execute_in_persistent_io_thread = WT_EXECUTEINPERSISTENTIOTHREAD_;
122 const ULONG_ wt_execute_in_persistent_thread = WT_EXECUTEINPERSISTENTTHREAD_;
123 const ULONG_ wt_transfer_impersonation = WT_TRANSFER_IMPERSONATION_;
128 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K
129 #endif // BOOST_WINAPI_THREAD_POOL_HPP_INCLUDED_