Commit ba5a6436 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz/systemclock: Clarify some field names.

parent b5eff130
...@@ -29,8 +29,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz); ...@@ -29,8 +29,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz);
struct advise_sink struct advise_sink
{ {
struct list entry; struct list entry;
HANDLE hEvent; HANDLE handle;
REFERENCE_TIME rtBaseTime, rtIntervalTime; REFERENCE_TIME due_time, period;
}; };
typedef struct SystemClockImpl { typedef struct SystemClockImpl {
...@@ -40,7 +40,7 @@ typedef struct SystemClockImpl { ...@@ -40,7 +40,7 @@ typedef struct SystemClockImpl {
BOOL thread_created; BOOL thread_created;
HANDLE thread, notify_event, stop_event; HANDLE thread, notify_event, stop_event;
REFERENCE_TIME last_time; REFERENCE_TIME last_time;
CRITICAL_SECTION safe; CRITICAL_SECTION cs;
/* These lists are ordered by expiration time (soonest first). */ /* These lists are ordered by expiration time (soonest first). */
struct list single_sinks, periodic_sinks; struct list single_sinks, periodic_sinks;
...@@ -53,12 +53,12 @@ static inline SystemClockImpl *impl_from_IReferenceClock(IReferenceClock *iface) ...@@ -53,12 +53,12 @@ static inline SystemClockImpl *impl_from_IReferenceClock(IReferenceClock *iface)
static void insert_advise_sink(struct advise_sink *sink, struct list *queue) static void insert_advise_sink(struct advise_sink *sink, struct list *queue)
{ {
REFERENCE_TIME due_time = sink->rtBaseTime + sink->rtIntervalTime; REFERENCE_TIME due_time = sink->due_time + sink->period;
struct advise_sink *cursor; struct advise_sink *cursor;
LIST_FOR_EACH_ENTRY(cursor, queue, struct advise_sink, entry) LIST_FOR_EACH_ENTRY(cursor, queue, struct advise_sink, entry)
{ {
if (cursor->rtBaseTime + cursor->rtIntervalTime > due_time) if (cursor->due_time + cursor->period > due_time)
{ {
list_add_before(&cursor->entry, &sink->entry); list_add_before(&cursor->entry, &sink->entry);
return; return;
...@@ -79,17 +79,17 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) { ...@@ -79,17 +79,17 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) {
TRACE("(%p): Main Loop\n", This); TRACE("(%p): Main Loop\n", This);
while (TRUE) { while (TRUE) {
EnterCriticalSection(&This->safe); EnterCriticalSection(&This->cs);
curTime = GetTickCount64() * 10000; curTime = GetTickCount64() * 10000;
/** First SingleShots Advice: sorted list */ /** First SingleShots Advice: sorted list */
LIST_FOR_EACH_ENTRY_SAFE(sink, cursor, &This->single_sinks, struct advise_sink, entry) LIST_FOR_EACH_ENTRY_SAFE(sink, cursor, &This->single_sinks, struct advise_sink, entry)
{ {
if (sink->rtBaseTime + sink->rtIntervalTime > curTime) if (sink->due_time + sink->period > curTime)
break; break;
SetEvent(sink->hEvent); SetEvent(sink->handle);
list_remove(&sink->entry); list_remove(&sink->entry);
heap_free(sink); heap_free(sink);
} }
...@@ -97,23 +97,23 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) { ...@@ -97,23 +97,23 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) {
if ((entry = list_head(&This->single_sinks))) if ((entry = list_head(&This->single_sinks)))
{ {
sink = LIST_ENTRY(entry, struct advise_sink, entry); sink = LIST_ENTRY(entry, struct advise_sink, entry);
timeOut = (sink->rtBaseTime + sink->rtIntervalTime - curTime) / 10000; timeOut = (sink->due_time + sink->period - curTime) / 10000;
} }
else timeOut = INFINITE; else timeOut = INFINITE;
/** Now Periodics Advice: semi sorted list (sort cannot be used) */ /** Now Periodics Advice: semi sorted list (sort cannot be used) */
LIST_FOR_EACH_ENTRY(sink, &This->periodic_sinks, struct advise_sink, entry) LIST_FOR_EACH_ENTRY(sink, &This->periodic_sinks, struct advise_sink, entry)
{ {
if (sink->rtBaseTime <= curTime) if (sink->due_time <= curTime)
{ {
DWORD periods = ((curTime - sink->rtBaseTime) / sink->rtIntervalTime) + 1; DWORD periods = ((curTime - sink->due_time) / sink->period) + 1;
ReleaseSemaphore(sink->hEvent, periods, NULL); ReleaseSemaphore(sink->handle, periods, NULL);
sink->rtBaseTime += periods * sink->rtIntervalTime; sink->due_time += periods * sink->period;
} }
timeOut = min(timeOut, (sink->rtBaseTime - curTime) / 10000); timeOut = min(timeOut, (sink->due_time - curTime) / 10000);
} }
LeaveCriticalSection(&This->safe); LeaveCriticalSection(&This->cs);
if (WaitForMultipleObjects(2, handles, FALSE, timeOut) == 0) if (WaitForMultipleObjects(2, handles, FALSE, timeOut) == 0)
return 0; return 0;
...@@ -173,8 +173,8 @@ static ULONG WINAPI SystemClockImpl_Release(IReferenceClock *iface) ...@@ -173,8 +173,8 @@ static ULONG WINAPI SystemClockImpl_Release(IReferenceClock *iface)
CloseHandle(clock->notify_event); CloseHandle(clock->notify_event);
CloseHandle(clock->stop_event); CloseHandle(clock->stop_event);
} }
clock->safe.DebugInfo->Spare[0] = 0; clock->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&clock->safe); DeleteCriticalSection(&clock->cs);
heap_free(clock); heap_free(clock);
} }
return refcount; return refcount;
...@@ -194,12 +194,12 @@ static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock *iface, REFERENCE_ ...@@ -194,12 +194,12 @@ static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock *iface, REFERENCE_
ret = GetTickCount64() * 10000; ret = GetTickCount64() * 10000;
EnterCriticalSection(&clock->safe); EnterCriticalSection(&clock->cs);
hr = (ret == clock->last_time) ? S_FALSE : S_OK; hr = (ret == clock->last_time) ? S_FALSE : S_OK;
*time = clock->last_time = ret; *time = clock->last_time = ret;
LeaveCriticalSection(&clock->safe); LeaveCriticalSection(&clock->cs);
return hr; return hr;
} }
...@@ -225,13 +225,13 @@ static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock *iface, ...@@ -225,13 +225,13 @@ static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock *iface,
if (!(sink = heap_alloc_zero(sizeof(*sink)))) if (!(sink = heap_alloc_zero(sizeof(*sink))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
sink->hEvent = (HANDLE)event; sink->handle = (HANDLE)event;
sink->rtBaseTime = base + offset; sink->due_time = base + offset;
sink->rtIntervalTime = 0; sink->period = 0;
EnterCriticalSection(&clock->safe); EnterCriticalSection(&clock->cs);
insert_advise_sink(sink, &clock->single_sinks); insert_advise_sink(sink, &clock->single_sinks);
LeaveCriticalSection(&clock->safe); LeaveCriticalSection(&clock->cs);
notify_thread(clock); notify_thread(clock);
...@@ -260,13 +260,13 @@ static HRESULT WINAPI SystemClockImpl_AdvisePeriodic(IReferenceClock* iface, ...@@ -260,13 +260,13 @@ static HRESULT WINAPI SystemClockImpl_AdvisePeriodic(IReferenceClock* iface,
if (!(sink = heap_alloc_zero(sizeof(*sink)))) if (!(sink = heap_alloc_zero(sizeof(*sink))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
sink->hEvent = (HANDLE)semaphore; sink->handle = (HANDLE)semaphore;
sink->rtBaseTime = start; sink->due_time = start;
sink->rtIntervalTime = period; sink->period = period;
EnterCriticalSection(&clock->safe); EnterCriticalSection(&clock->cs);
insert_advise_sink(sink, &clock->periodic_sinks); insert_advise_sink(sink, &clock->periodic_sinks);
LeaveCriticalSection(&clock->safe); LeaveCriticalSection(&clock->cs);
notify_thread(clock); notify_thread(clock);
...@@ -281,7 +281,7 @@ static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock *iface, DWORD_PTR ...@@ -281,7 +281,7 @@ static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock *iface, DWORD_PTR
TRACE("clock %p, cookie %#lx.\n", clock, cookie); TRACE("clock %p, cookie %#lx.\n", clock, cookie);
EnterCriticalSection(&clock->safe); EnterCriticalSection(&clock->cs);
LIST_FOR_EACH_ENTRY(sink, &clock->single_sinks, struct advise_sink, entry) LIST_FOR_EACH_ENTRY(sink, &clock->single_sinks, struct advise_sink, entry)
{ {
...@@ -289,7 +289,7 @@ static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock *iface, DWORD_PTR ...@@ -289,7 +289,7 @@ static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock *iface, DWORD_PTR
{ {
list_remove(&sink->entry); list_remove(&sink->entry);
heap_free(sink); heap_free(sink);
LeaveCriticalSection(&clock->safe); LeaveCriticalSection(&clock->cs);
return S_OK; return S_OK;
} }
} }
...@@ -300,12 +300,12 @@ static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock *iface, DWORD_PTR ...@@ -300,12 +300,12 @@ static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock *iface, DWORD_PTR
{ {
list_remove(&sink->entry); list_remove(&sink->entry);
heap_free(sink); heap_free(sink);
LeaveCriticalSection(&clock->safe); LeaveCriticalSection(&clock->cs);
return S_OK; return S_OK;
} }
} }
LeaveCriticalSection(&clock->safe); LeaveCriticalSection(&clock->cs);
return S_FALSE; return S_FALSE;
} }
...@@ -336,8 +336,8 @@ HRESULT QUARTZ_CreateSystemClock(IUnknown *outer, void **out) ...@@ -336,8 +336,8 @@ HRESULT QUARTZ_CreateSystemClock(IUnknown *outer, void **out)
object->IReferenceClock_iface.lpVtbl = &SystemClock_Vtbl; object->IReferenceClock_iface.lpVtbl = &SystemClock_Vtbl;
list_init(&object->single_sinks); list_init(&object->single_sinks);
list_init(&object->periodic_sinks); list_init(&object->periodic_sinks);
InitializeCriticalSection(&object->safe); InitializeCriticalSection(&object->cs);
object->safe.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SystemClockImpl.safe"); object->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SystemClockImpl.cs");
return SystemClockImpl_QueryInterface(&object->IReferenceClock_iface, &IID_IReferenceClock, out); return SystemClockImpl_QueryInterface(&object->IReferenceClock_iface, &IID_IReferenceClock, out);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment