[PATCH 3/3] winmm: Use fevent for timers.
Maarten Lankhorst
m.b.lankhorst at gmail.com
Sun May 13 09:31:01 CDT 2007
We want to block in timer as much as possible, normal events are simply
too costly and slow for something time critical.
-------------- next part --------------
>From dd8a323997da46a6c52b1091c6faf7a13e6f61e4 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Sat, 12 May 2007 20:41:08 +0200
Subject: [PATCH] winmm: use fevents
---
dlls/winmm/time.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c
index 27a4e46..7671370 100644
--- a/dlls/winmm/time.c
+++ b/dlls/winmm/time.c
@@ -39,15 +39,15 @@
#include "winemm.h"
#include "wine/debug.h"
+#include "wine/fevent.h"
WINE_DEFAULT_DEBUG_CHANNEL(mmtime);
static HANDLE TIME_hMMTimer;
static LPWINE_TIMERENTRY TIME_TimersList;
-static HANDLE TIME_hWakeEvent;
static CRITICAL_SECTION TIME_cbcrst;
static BOOL TIME_TimeToDie = TRUE;
-
+static FEVENT TIME_hWakeEvent;
/*
* Some observations on the behavior of winmm on Windows.
* First, the call to timeBeginPeriod(xx) can never be used
@@ -77,7 +77,6 @@ static BOOL TIME_TimeToDie = TRUE;
#define MMSYSTIME_MININTERVAL (1)
#define MMSYSTIME_MAXINTERVAL (65535)
-
static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer)
{
TRACE("%04x:CallBack => lpFunc=%p wTimerID=%04X dwUser=%08X dwTriggerTime %d(delta %d)\n",
@@ -244,9 +243,9 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
if (sleep_time == 0)
continue;
- rc = WaitForSingleObject(TIME_hWakeEvent, sleep_time);
+ rc = WAITEVENT(TIME_hWakeEvent, sleep_time);
if (rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0)
- {
+ {
FIXME("Unexpected error %d(%d) in timer thread\n", rc, GetLastError());
break;
}
@@ -261,10 +260,10 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
void TIME_MMTimeStart(void)
{
if (!TIME_hMMTimer) {
- TIME_TimersList = NULL;
- TIME_hWakeEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ TIME_TimersList = NULL;
+ TIME_hWakeEvent = CREATEEVENT(NULL, FALSE, FALSE, NULL);
TIME_TimeToDie = FALSE;
- TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, &WINMM_IData, 0, NULL);
+ 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");
@@ -279,14 +278,14 @@ void TIME_MMTimeStop(void)
if (TIME_hMMTimer) {
TIME_TimeToDie = TRUE;
- SetEvent(TIME_hWakeEvent);
+ SETEVENT(TIME_hWakeEvent);
/* FIXME: in the worst case, we're going to wait 65 seconds here :-( */
- WaitForSingleObject(TIME_hMMTimer, INFINITE);
+ WaitForSingleObject(TIME_hMMTimer, INFINITE);
- CloseHandle(TIME_hMMTimer);
- CloseHandle(TIME_hWakeEvent);
- TIME_hMMTimer = 0;
+ CloseHandle(TIME_hMMTimer);
+ CLOSEEVENT(TIME_hWakeEvent);
+ TIME_hMMTimer = 0;
TIME_cbcrst.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&TIME_cbcrst);
TIME_TimersList = NULL;
@@ -352,7 +351,7 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
LeaveCriticalSection(&WINMM_IData.cs);
/* Wake the service thread in case there is work to be done */
- SetEvent(TIME_hWakeEvent);
+ SETEVENT(TIME_hWakeEvent);
TRACE("=> %u\n", wNewID + 1);
--
1.4.4.2
More information about the wine-patches
mailing list