blob: a45a8b5e81b18789cfbf9f97bdfc192e8b03269e (
plain) (
blame)
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
|
//+-------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1992 - 1993.
//
// File: signal.cxx
//
// Contents: Signal class implementation
//
// Classes: CSignal
//
// History: 29-Sep-93 CarlH Created
//
//--------------------------------------------------------------------------
#include <windows.h>
#include "signal.hxx"
#pragma hdrstop
CSignal::CSignal(WCHAR const *pwszName) :
_pwszName(new WCHAR[wcslen(pwszName) + 1]),
_hevent(0)
{
wcscpy(_pwszName, pwszName);
}
CSignal::~CSignal(void)
{
delete _pwszName;
if (_hevent != 0)
{
CloseHandle(_hevent);
}
}
DWORD CSignal::Wait(DWORD dwTimeout)
{
DWORD stat = 0;
if (_hevent == 0)
{
_hevent = CreateEvent(NULL, TRUE, FALSE, _pwszName);
if (_hevent == 0)
{
stat = GetLastError();
}
}
if (stat == 0)
{
stat = WaitForSingleObject(_hevent, dwTimeout);
if (stat == 0)
{
ResetEvent(_hevent);
}
}
return (stat);
}
DWORD CSignal::Signal(void)
{
DWORD stat = 0;
if (_hevent == 0)
{
_hevent = CreateEvent(NULL, TRUE, FALSE, _pwszName);
if (_hevent == 0)
{
stat = GetLastError();
}
}
if (stat == 0)
{
if (!SetEvent(_hevent))
{
stat = GetLastError();
}
}
return (stat);
}
|