1 // waitable_timer.hpp --------------------------------------------------------------//
3 // Copyright 2013 Andrey Semashev
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
9 #ifndef BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP
10 #define BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP
12 #include <boost/detail/winapi/basic_types.hpp>
14 #ifdef BOOST_HAS_PRAGMA_ONCE
18 #if !defined( BOOST_USE_WINDOWS_H )
20 typedef boost::detail::winapi::VOID_
21 (WINAPI *PTIMERAPCROUTINE)(
22 boost::detail::winapi::LPVOID_ lpArgToCompletionRoutine,
23 boost::detail::winapi::DWORD_ dwTimerLowValue,
24 boost::detail::winapi::DWORD_ dwTimerHighValue);
26 #if !defined( BOOST_NO_ANSI_APIS )
27 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
29 ::_SECURITY_ATTRIBUTES* lpTimerAttributes,
30 boost::detail::winapi::BOOL_ bManualReset,
31 boost::detail::winapi::LPCSTR_ lpTimerName);
33 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
35 boost::detail::winapi::DWORD_ dwDesiredAccess,
36 boost::detail::winapi::BOOL_ bInheritHandle,
37 boost::detail::winapi::LPCSTR_ lpTimerName);
40 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
42 ::_SECURITY_ATTRIBUTES* lpTimerAttributes,
43 boost::detail::winapi::BOOL_ bManualReset,
44 boost::detail::winapi::LPCWSTR_ lpTimerName);
46 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
48 boost::detail::winapi::DWORD_ dwDesiredAccess,
49 boost::detail::winapi::BOOL_ bInheritHandle,
50 boost::detail::winapi::LPCWSTR_ lpTimerName);
52 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
54 boost::detail::winapi::HANDLE_ hTimer,
55 const ::_LARGE_INTEGER* lpDueTime,
56 boost::detail::winapi::LONG_ lPeriod,
57 PTIMERAPCROUTINE pfnCompletionRoutine,
58 boost::detail::winapi::LPVOID_ lpArgToCompletionRoutine,
59 boost::detail::winapi::BOOL_ fResume);
61 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
62 CancelWaitableTimer(boost::detail::winapi::HANDLE_ hTimer);
70 typedef ::PTIMERAPCROUTINE PTIMERAPCROUTINE_;
72 #if !defined( BOOST_NO_ANSI_APIS )
73 using ::OpenWaitableTimerA;
75 using ::OpenWaitableTimerW;
76 using ::CancelWaitableTimer;
78 #if defined( BOOST_USE_WINDOWS_H )
80 const DWORD_ TIMER_ALL_ACCESS_ = TIMER_ALL_ACCESS;
81 const DWORD_ TIMER_MODIFY_STATE_ = TIMER_MODIFY_STATE;
82 const DWORD_ TIMER_QUERY_STATE_ = TIMER_QUERY_STATE;
84 #else // defined( BOOST_USE_WINDOWS_H )
86 const DWORD_ TIMER_ALL_ACCESS_ = 0x001F0003;
87 const DWORD_ TIMER_MODIFY_STATE_ = 0x00000002;
88 const DWORD_ TIMER_QUERY_STATE_ = 0x00000001;
90 #endif // defined( BOOST_USE_WINDOWS_H )
92 const DWORD_ timer_all_access = TIMER_ALL_ACCESS_;
93 const DWORD_ timer_modify_state = TIMER_MODIFY_STATE_;
94 const DWORD_ timer_query_state = TIMER_QUERY_STATE_;
97 #if !defined( BOOST_NO_ANSI_APIS )
98 BOOST_FORCEINLINE HANDLE_ CreateWaitableTimerA(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCSTR_ lpTimerName)
100 return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName);
104 BOOST_FORCEINLINE HANDLE_ CreateWaitableTimerW(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCWSTR_ lpTimerName)
106 return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName);
109 BOOST_FORCEINLINE BOOL_ SetWaitableTimer(
111 const LARGE_INTEGER_* lpDueTime,
113 PTIMERAPCROUTINE_ pfnCompletionRoutine,
114 LPVOID_ lpArgToCompletionRoutine,
117 return ::SetWaitableTimer(hTimer, reinterpret_cast< const ::_LARGE_INTEGER* >(lpDueTime), lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, fResume);
120 #if !defined( BOOST_NO_ANSI_APIS )
121 BOOST_FORCEINLINE HANDLE_ create_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCSTR_ lpTimerName)
123 return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName);
127 BOOST_FORCEINLINE HANDLE_ create_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCWSTR_ lpTimerName)
129 return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName);
132 BOOST_FORCEINLINE HANDLE_ create_anonymous_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset)
134 #ifdef BOOST_NO_ANSI_APIS
135 return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, 0);
137 return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, 0);
145 #endif // BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP