winmm: Use criticalsection for determining wether timer is
synchronously killable
Maarten Lankhorst
m.b.lankhorst at gmail.com
Sat May 5 10:32:24 CDT 2007
It makes more sense to use a critical section here then to use an event
to synchronize.
-------------- next part --------------
>From b50aecc65db3a539f58c6a61fc038bdc152c9ac5 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Thu, 3 May 2007 18:16:18 +0200
Subject: [PATCH] winmm: Use criticalsection for signalling object is killable
---
dlls/winmm/time.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c
index 891b569..27a4e46 100644
--- a/dlls/winmm/time.c
+++ b/dlls/winmm/time.c
@@ -44,8 +44,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmtime);
static HANDLE TIME_hMMTimer;
static LPWINE_TIMERENTRY TIME_TimersList;
-static HANDLE TIME_hKillEvent;
static HANDLE TIME_hWakeEvent;
+static CRITICAL_SECTION TIME_cbcrst;
static BOOL TIME_TimeToDie = TRUE;
/*
@@ -200,11 +200,11 @@ static LPWINE_TIMERENTRY lpTimers;
ptimer = next_ptimer;
}
- if (TIME_hKillEvent) ResetEvent(TIME_hKillEvent);
LeaveCriticalSection(&iData->cs);
+ EnterCriticalSection(&TIME_cbcrst);
while (idx > 0) TIME_TriggerCallBack(&lpTimers[--idx]);
- if (TIME_hKillEvent) SetEvent(TIME_hKillEvent);
+ LeaveCriticalSection(&TIME_cbcrst);
/* Finally, adjust the recommended wait time downward
by the amount of time the processing routines
@@ -266,6 +266,8 @@ void TIME_MMTimeStart(void)
TIME_TimeToDie = FALSE;
TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, &WINMM_IData, 0, NULL);
SetThreadPriority(TIME_hMMTimer, THREAD_PRIORITY_TIME_CRITICAL);
+ InitializeCriticalSection(&TIME_cbcrst);
+ TIME_cbcrst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": WINMM.TIME_cbcrst");
}
}
@@ -285,6 +287,8 @@ void TIME_MMTimeStop(void)
CloseHandle(TIME_hMMTimer);
CloseHandle(TIME_hWakeEvent);
TIME_hMMTimer = 0;
+ TIME_cbcrst.DebugInfo->Spare[0] = 0;
+ DeleteCriticalSection(&TIME_cbcrst);
TIME_TimersList = NULL;
}
}
@@ -337,9 +341,6 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
EnterCriticalSection(&WINMM_IData.cs);
- if ((wFlags & TIME_KILL_SYNCHRONOUS) && !TIME_hKillEvent)
- TIME_hKillEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
-
for (lpTimer = TIME_TimersList; lpTimer != NULL; lpTimer = lpTimer->lpNext) {
wNewID = max(wNewID, lpTimer->wTimerID);
}
@@ -397,8 +398,10 @@ MMRESULT WINAPI timeKillEvent(UINT wID)
return MMSYSERR_INVALPARAM;
}
if (lpSelf->wFlags & TIME_KILL_SYNCHRONOUS)
- WaitForSingleObject(TIME_hKillEvent, INFINITE);
+ EnterCriticalSection(&TIME_cbcrst);
HeapFree(GetProcessHeap(), 0, lpSelf);
+ if (lpSelf->wFlags & TIME_KILL_SYNCHRONOUS)
+ LeaveCriticalSection(&TIME_cbcrst);
return TIMERR_NOERROR;
}
--
1.4.4.2
More information about the wine-patches
mailing list