Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/rtworkq/queue.c | 40 +++++++++++++++++++++++++++++++++++++++ dlls/rtworkq/rtworkq.spec | 2 +- include/rtworkq.idl | 1 + 3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/dlls/rtworkq/queue.c b/dlls/rtworkq/queue.c index 7d949e8e62..2797f292ce 100644 --- a/dlls/rtworkq/queue.c +++ b/dlls/rtworkq/queue.c @@ -465,6 +465,33 @@ static HRESULT queue_submit_wait(struct queue *queue, HANDLE event, LONG priorit return S_OK; }
+static HRESULT queue_cancel_item(struct queue *queue, RTWQWORKITEM_KEY key) +{ + HRESULT hr = RTWQ_E_NOT_FOUND; + struct work_item *item; + + EnterCriticalSection(&queue->cs); + LIST_FOR_EACH_ENTRY(item, &queue->pending_items, struct work_item, entry) + { + if (item->key == key) + { + key >>= 32; + if ((key & WAIT_ITEM_KEY_MASK) == WAIT_ITEM_KEY_MASK) + CloseThreadpoolWait(item->u.wait_object); + else if ((key & SCHEDULED_ITEM_KEY_MASK) == SCHEDULED_ITEM_KEY_MASK) + CloseThreadpoolTimer(item->u.timer_object); + else + WARN("Unknown item key mask %#x.\n", (DWORD)key); + queue_release_pending_item(item); + hr = S_OK; + break; + } + } + LeaveCriticalSection(&queue->cs); + + return hr; +} + struct async_result { RTWQASYNCRESULT result; @@ -724,6 +751,19 @@ HRESULT WINAPI RtwqPutWaitingWorkItem(HANDLE event, LONG priority, IRtwqAsyncRes return hr; }
+HRESULT WINAPI RtwqCancelWorkItem(RTWQWORKITEM_KEY key) +{ + struct queue *queue; + HRESULT hr; + + TRACE("%s.\n", wine_dbgstr_longlong(key)); + + if (FAILED(hr = grab_queue(RTWQ_CALLBACK_QUEUE_TIMER, &queue))) + return hr; + + return queue_cancel_item(queue, key); +} + HRESULT WINAPI RtwqLockWorkQueue(DWORD queue) { TRACE("%#x.\n", queue); diff --git a/dlls/rtworkq/rtworkq.spec b/dlls/rtworkq/rtworkq.spec index 47e1c1b2ae..04da2a9573 100644 --- a/dlls/rtworkq/rtworkq.spec +++ b/dlls/rtworkq/rtworkq.spec @@ -5,7 +5,7 @@ @ stub RtwqBeginUnregisterWorkQueueWithMMCSS @ stub RtwqCancelDeadline @ stub RtwqCancelMultipleWaitingWorkItem -@ stub RtwqCancelWorkItem +@ stdcall RtwqCancelWorkItem(int64) @ stdcall RtwqCreateAsyncResult(ptr ptr ptr ptr) @ stub RtwqEndRegisterWorkQueueWithMMCSS @ stub RtwqEndUnregisterWorkQueueWithMMCSS diff --git a/include/rtworkq.idl b/include/rtworkq.idl index a899376e92..8cc205a7eb 100644 --- a/include/rtworkq.idl +++ b/include/rtworkq.idl @@ -75,6 +75,7 @@ cpp_quote(" DWORD dwBytesTransferred;") cpp_quote(" HANDLE hEvent;") cpp_quote("} RTWQASYNCRESULT;")
+cpp_quote("HRESULT WINAPI RtwqCancelWorkItem(RTWQWORKITEM_KEY key);") cpp_quote("HRESULT WINAPI RtwqCreateAsyncResult(IUnknown *object, IRtwqAsyncCallback *callback, IUnknown *state, IRtwqAsyncResult **result);") cpp_quote("HRESULT WINAPI RtwqLockPlatform(void);") cpp_quote("HRESULT WINAPI RtwqLockWorkQueue(DWORD queue);")