-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaitable_timer.hpp
110 lines (87 loc) · 2.23 KB
/
waitable_timer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// waitable_timer.hpp --------------------------------------------------------------//
// Copyright 2013 Andrey Semashev
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP
#define BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP
#include <boost/detail/winapi/basic_types.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost
{
namespace detail
{
namespace winapi
{
#if defined( BOOST_USE_WINDOWS_H )
typedef ::PTIMERAPCROUTINE PTIMERAPCROUTINE_;
# ifdef BOOST_NO_ANSI_APIS
using ::CreateWaitableTimerW;
using ::OpenWaitableTimerW;
# else
using ::CreateWaitableTimerA;
using ::OpenWaitableTimerA;
# endif
using ::SetWaitableTimer;
using ::CancelWaitableTimer;
#else
extern "C" {
struct _SECURITY_ATTRIBUTES;
typedef void (WINAPI* PTIMERAPCROUTINE_)
(
LPVOID_ lpArgToCompletionRoutine,
DWORD_ dwTimerLowValue,
DWORD_ dwTimerHighValue
);
# ifdef BOOST_NO_ANSI_APIS
__declspec(dllimport) HANDLE_ WINAPI CreateWaitableTimerW
(
_SECURITY_ATTRIBUTES* lpTimerAttributes,
BOOL_ bManualReset,
LPCWSTR_ lpTimerName
);
__declspec(dllimport) HANDLE_ WINAPI OpenWaitableTimerW
(
DWORD_ dwDesiredAccess,
BOOL_ bInheritHandle,
LPCWSTR_ lpTimerName
);
# else
__declspec(dllimport) HANDLE_ WINAPI CreateWaitableTimerA
(
_SECURITY_ATTRIBUTES* lpTimerAttributes,
BOOL_ bManualReset,
LPCSTR_ lpTimerName
);
__declspec(dllimport) HANDLE_ WINAPI OpenWaitableTimerA
(
DWORD_ dwDesiredAccess,
BOOL_ bInheritHandle,
LPCSTR_ lpTimerName
);
# endif
__declspec(dllimport) BOOL_ WINAPI SetWaitableTimer
(
HANDLE_ hTimer,
const LARGE_INTEGER_ *lpDueTime,
LONG_ lPeriod,
PTIMERAPCROUTINE_ pfnCompletionRoutine,
LPVOID_ lpArgToCompletionRoutine,
BOOL_ fResume
);
__declspec(dllimport) BOOL_ WINAPI CancelWaitableTimer(HANDLE_ hTimer);
}
#endif
BOOST_FORCEINLINE HANDLE_ create_anonymous_waitable_timer(_SECURITY_ATTRIBUTES* lpTimerAttributes, BOOL_ bManualReset)
{
#ifdef BOOST_NO_ANSI_APIS
return CreateWaitableTimerW(lpTimerAttributes, bManualReset, 0);
#else
return CreateWaitableTimerA(lpTimerAttributes, bManualReset, 0);
#endif
}
}
}
}
#endif // BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP