Stop timer in ~EventWindows().

Running out of handles seems to have been an issue when adding another
test target, this should solve it.

BUG=
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2339004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4897 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2013-10-02 13:11:15 +00:00
parent a6101d76f4
commit c0167702d3

View File

@ -23,16 +23,17 @@ EventWindows::EventWindows()
} }
EventWindows::~EventWindows() { EventWindows::~EventWindows() {
StopTimer();
CloseHandle(event_); CloseHandle(event_);
} }
bool EventWindows::Set() { bool EventWindows::Set() {
// Note: setting an event that is already set has no effect. // Note: setting an event that is already set has no effect.
return SetEvent(event_) == 1 ? true : false; return SetEvent(event_) == 1;
} }
bool EventWindows::Reset() { bool EventWindows::Reset() {
return ResetEvent(event_) == 1 ? true : false; return ResetEvent(event_) == 1;
} }
EventTypeWrapper EventWindows::Wait(unsigned long max_time) { EventTypeWrapper EventWindows::Wait(unsigned long max_time) {
@ -52,6 +53,7 @@ bool EventWindows::StartTimer(bool periodic, unsigned long time) {
timeKillEvent(timerID_); timeKillEvent(timerID_);
timerID_ = NULL; timerID_ = NULL;
} }
if (periodic) { if (periodic) {
timerID_ = timeSetEvent(time, 0, (LPTIMECALLBACK)HANDLE(event_), 0, timerID_ = timeSetEvent(time, 0, (LPTIMECALLBACK)HANDLE(event_), 0,
TIME_PERIODIC | TIME_CALLBACK_EVENT_PULSE); TIME_PERIODIC | TIME_CALLBACK_EVENT_PULSE);
@ -60,15 +62,15 @@ bool EventWindows::StartTimer(bool periodic, unsigned long time) {
TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); TIME_ONESHOT | TIME_CALLBACK_EVENT_SET);
} }
if (timerID_ == NULL) { return timerID_ != NULL;
return false;
}
return true;
} }
bool EventWindows::StopTimer() { bool EventWindows::StopTimer() {
timeKillEvent(timerID_); if (timerID_ != NULL) {
timerID_ = NULL; timeKillEvent(timerID_);
timerID_ = NULL;
}
return true; return true;
} }