ReactOS 0.4.17-dev-691-gfdddc52
queue.c File Reference
#include <assert.h>
#include "initguid.h"
#include "rtworkq.h"
#include "wine/debug.h"
#include "wine/list.h"
Include dependency graph for queue.c:

Go to the source code of this file.

Classes

struct  queue_handle
 
struct  work_item
 
struct  queue_ops
 
struct  queue_desc
 
class  queue< _Tp, _Sequence >
 
struct  async_result
 
struct  periodic_callback
 

Macros

#define COBJMACROS
 
#define FIRST_USER_QUEUE_HANDLE   5
 
#define MAX_USER_QUEUE_HANDLES   124
 
#define WAIT_ITEM_KEY_MASK   (0x82000000)
 
#define SCHEDULED_ITEM_KEY_MASK   (0x80000000)
 

Enumerations

enum  rtwq_callback_queue_id {
  RTWQ_CALLBACK_QUEUE_UNDEFINED = 0x00000000 , RTWQ_CALLBACK_QUEUE_STANDARD = 0x00000001 , RTWQ_CALLBACK_QUEUE_RT = 0x00000002 , RTWQ_CALLBACK_QUEUE_IO = 0x00000003 ,
  RTWQ_CALLBACK_QUEUE_TIMER = 0x00000004 , RTWQ_CALLBACK_QUEUE_MULTITHREADED = 0x00000005 , RTWQ_CALLBACK_QUEUE_LONG_FUNCTION = 0x00000007 , RTWQ_CALLBACK_QUEUE_PRIVATE_MASK = 0xffff0000 ,
  RTWQ_CALLBACK_QUEUE_ALL = 0xffffffff
}
 
enum  rtwq_callback_flags {
  RTWQ_FAST_IO_PROCESSING_CALLBACK = 0x00000001 , RTWQ_SIGNAL_CALLBACK = 0x00000002 , RTWQ_BLOCKING_CALLBACK = 0x00000004 , RTWQ_REPLY_CALLBACK = 0x00000008 ,
  RTWQ_LOCALIZE_REMOTE_CALLBACK = 0x00000010
}
 
enum  system_queue_index {
  SYS_QUEUE_STANDARD = 0 , SYS_QUEUE_RT , SYS_QUEUE_IO , SYS_QUEUE_TIMER ,
  SYS_QUEUE_MULTITHREADED , SYS_QUEUE_DO_NOT_USE , SYS_QUEUE_LONG_FUNCTION , SYS_QUEUE_COUNT
}
 
enum  work_item_type { WORK_ITEM_WORK , WORK_ITEM_TIMER , WORK_ITEM_WAIT }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (mfplat)
 
static RTWQWORKITEM_KEY get_item_key (DWORD mask, DWORD key)
 
static RTWQWORKITEM_KEY generate_item_key (DWORD mask)
 
static struct queue_handleget_queue_obj (DWORD handle)
 
static struct work_itemwork_item_impl_from_IUnknown (IUnknown *iface)
 
static void shutdown_queue (struct queue *queue)
 
static HRESULT lock_user_queue (DWORD queue)
 
static HRESULT unlock_user_queue (DWORD queue)
 
static struct queuequeue_impl_from_IRtwqAsyncCallback (IRtwqAsyncCallback *iface)
 
static HRESULT WINAPI queue_serial_callback_QueryInterface (IRtwqAsyncCallback *iface, REFIID riid, void **obj)
 
static ULONG WINAPI queue_serial_callback_AddRef (IRtwqAsyncCallback *iface)
 
static ULONG WINAPI queue_serial_callback_Release (IRtwqAsyncCallback *iface)
 
static HRESULT WINAPI queue_serial_callback_GetParameters (IRtwqAsyncCallback *iface, DWORD *flags, DWORD *queue_id)
 
static HRESULT WINAPI queue_serial_callback_Invoke (IRtwqAsyncCallback *iface, IRtwqAsyncResult *result)
 
static struct queueget_system_queue (DWORD queue_id)
 
static HRESULT grab_queue (DWORD queue_id, struct queue **ret)
 
static void CALLBACK standard_queue_cleanup_callback (void *object_data, void *group_data)
 
static HRESULT pool_queue_init (const struct queue_desc *desc, struct queue *queue)
 
static BOOL pool_queue_shutdown (struct queue *queue)
 
static void CALLBACK standard_queue_worker (TP_CALLBACK_INSTANCE *instance, void *context, TP_WORK *work)
 
static void pool_queue_submit (struct queue *queue, struct work_item *item)
 
static struct work_itemserial_queue_get_next (struct queue *queue, struct work_item *item)
 
static void CALLBACK serial_queue_finalization_callback (PTP_CALLBACK_INSTANCE instance, void *user_data)
 
static HRESULT serial_queue_init (const struct queue_desc *desc, struct queue *queue)
 
static BOOL serial_queue_shutdown (struct queue *queue)
 
static struct work_itemserial_queue_is_ack_token (struct queue *queue, struct work_item *item)
 
static void serial_queue_submit (struct queue *queue, struct work_item *item)
 
static HRESULT WINAPI work_item_QueryInterface (IUnknown *iface, REFIID riid, void **obj)
 
static ULONG WINAPI work_item_AddRef (IUnknown *iface)
 
static ULONG WINAPI work_item_Release (IUnknown *iface)
 
static struct work_itemalloc_work_item (struct queue *queue, LONG priority, IRtwqAsyncResult *result)
 
static void init_work_queue (const struct queue_desc *desc, struct queue *queue)
 
static HRESULT queue_submit_item (struct queue *queue, LONG priority, IRtwqAsyncResult *result)
 
static HRESULT queue_put_work_item (DWORD queue_id, LONG priority, IRtwqAsyncResult *result)
 
static HRESULT invoke_async_callback (IRtwqAsyncResult *result)
 
static BOOL queue_release_pending_item (struct work_item *item)
 
static void CALLBACK waiting_item_callback (TP_CALLBACK_INSTANCE *instance, void *context, TP_WAIT *wait, TP_WAIT_RESULT wait_result)
 
static void CALLBACK waiting_item_cancelable_callback (TP_CALLBACK_INSTANCE *instance, void *context, TP_WAIT *wait, TP_WAIT_RESULT wait_result)
 
static void CALLBACK scheduled_item_callback (TP_CALLBACK_INSTANCE *instance, void *context, TP_TIMER *timer)
 
static void CALLBACK scheduled_item_cancelable_callback (TP_CALLBACK_INSTANCE *instance, void *context, TP_TIMER *timer)
 
static void CALLBACK periodic_item_callback (TP_CALLBACK_INSTANCE *instance, void *context, TP_TIMER *timer)
 
static void queue_mark_item_pending (DWORD mask, struct work_item *item, RTWQWORKITEM_KEY *key)
 
static HRESULT queue_submit_wait (struct queue *queue, HANDLE event, LONG priority, IRtwqAsyncResult *result, RTWQWORKITEM_KEY *key)
 
static HRESULT queue_submit_timer (struct queue *queue, IRtwqAsyncResult *result, INT64 timeout, DWORD period, RTWQWORKITEM_KEY *key)
 
static HRESULT queue_cancel_item (struct queue *queue, RTWQWORKITEM_KEY key)
 
static HRESULT alloc_user_queue (const struct queue_desc *desc, DWORD *queue_id)
 
static struct async_resultimpl_from_IRtwqAsyncResult (IRtwqAsyncResult *iface)
 
static HRESULT WINAPI async_result_QueryInterface (IRtwqAsyncResult *iface, REFIID riid, void **obj)
 
static ULONG WINAPI async_result_AddRef (IRtwqAsyncResult *iface)
 
static ULONG WINAPI async_result_Release (IRtwqAsyncResult *iface)
 
static HRESULT WINAPI async_result_GetState (IRtwqAsyncResult *iface, IUnknown **state)
 
static HRESULT WINAPI async_result_GetStatus (IRtwqAsyncResult *iface)
 
static HRESULT WINAPI async_result_SetStatus (IRtwqAsyncResult *iface, HRESULT status)
 
static HRESULT WINAPI async_result_GetObject (IRtwqAsyncResult *iface, IUnknown **object)
 
static IUnknown *WINAPI async_result_GetStateNoAddRef (IRtwqAsyncResult *iface)
 
static HRESULT create_async_result (IUnknown *object, IRtwqAsyncCallback *callback, IUnknown *state, IRtwqAsyncResult **out)
 
HRESULT WINAPI RtwqCreateAsyncResult (IUnknown *object, IRtwqAsyncCallback *callback, IUnknown *state, IRtwqAsyncResult **out)
 
HRESULT WINAPI RtwqLockPlatform (void)
 
HRESULT WINAPI RtwqUnlockPlatform (void)
 
static void init_system_queues (void)
 
HRESULT WINAPI RtwqStartup (void)
 
static void shutdown_system_queues (void)
 
HRESULT WINAPI RtwqShutdown (void)
 
HRESULT WINAPI RtwqPutWaitingWorkItem (HANDLE event, LONG priority, IRtwqAsyncResult *result, RTWQWORKITEM_KEY *key)
 
static HRESULT schedule_work_item (IRtwqAsyncResult *result, INT64 timeout, RTWQWORKITEM_KEY *key)
 
HRESULT WINAPI RtwqScheduleWorkItem (IRtwqAsyncResult *result, INT64 timeout, RTWQWORKITEM_KEY *key)
 
static struct periodic_callbackimpl_from_IRtwqAsyncCallback (IRtwqAsyncCallback *iface)
 
static HRESULT WINAPI periodic_callback_QueryInterface (IRtwqAsyncCallback *iface, REFIID riid, void **obj)
 
static ULONG WINAPI periodic_callback_AddRef (IRtwqAsyncCallback *iface)
 
static ULONG WINAPI periodic_callback_Release (IRtwqAsyncCallback *iface)
 
static HRESULT WINAPI periodic_callback_GetParameters (IRtwqAsyncCallback *iface, DWORD *flags, DWORD *queue)
 
static HRESULT WINAPI periodic_callback_Invoke (IRtwqAsyncCallback *iface, IRtwqAsyncResult *result)
 
static HRESULT create_periodic_callback_obj (RTWQPERIODICCALLBACK callback, IRtwqAsyncCallback **out)
 
HRESULT WINAPI RtwqAddPeriodicCallback (RTWQPERIODICCALLBACK callback, IUnknown *context, DWORD *key)
 
HRESULT WINAPI RtwqRemovePeriodicCallback (DWORD key)
 
HRESULT WINAPI RtwqCancelWorkItem (RTWQWORKITEM_KEY key)
 
HRESULT WINAPI RtwqInvokeCallback (IRtwqAsyncResult *result)
 
HRESULT WINAPI RtwqPutWorkItem (DWORD queue, LONG priority, IRtwqAsyncResult *result)
 
HRESULT WINAPI RtwqAllocateWorkQueue (RTWQ_WORKQUEUE_TYPE queue_type, DWORD *queue)
 
HRESULT WINAPI RtwqLockWorkQueue (DWORD queue)
 
HRESULT WINAPI RtwqUnlockWorkQueue (DWORD queue)
 
HRESULT WINAPI RtwqSetLongRunning (DWORD queue_id, BOOL enable)
 
HRESULT WINAPI RtwqLockSharedWorkQueue (const WCHAR *usageclass, LONG priority, DWORD *taskid, DWORD *queue)
 
HRESULT WINAPI RtwqSetDeadline (DWORD queue_id, LONGLONG deadline, HANDLE *request)
 
HRESULT WINAPI RtwqSetDeadline2 (DWORD queue_id, LONGLONG deadline, LONGLONG predeadline, HANDLE *request)
 
HRESULT WINAPI RtwqCancelDeadline (HANDLE request)
 
HRESULT WINAPI RtwqAllocateSerialWorkQueue (DWORD target_queue, DWORD *queue)
 
HRESULT WINAPI RtwqJoinWorkQueue (DWORD queue, HANDLE hFile, HANDLE *cookie)
 
HRESULT WINAPI RtwqUnjoinWorkQueue (DWORD queue, HANDLE cookie)
 
HRESULT WINAPI RtwqGetWorkQueueMMCSSClass (DWORD queue, WCHAR *class, DWORD *length)
 
HRESULT WINAPI RtwqGetWorkQueueMMCSSTaskId (DWORD queue, DWORD *taskid)
 
HRESULT WINAPI RtwqGetWorkQueueMMCSSPriority (DWORD queue, LONG *priority)
 
HRESULT WINAPI RtwqRegisterPlatformWithMMCSS (const WCHAR *class, DWORD *taskid, LONG priority)
 
HRESULT WINAPI RtwqUnregisterPlatformFromMMCSS (void)
 
HRESULT WINAPI RtwqBeginRegisterWorkQueueWithMMCSS (DWORD queue, const WCHAR *class, DWORD taskid, LONG priority, IRtwqAsyncCallback *callback, IUnknown *state)
 
HRESULT WINAPI RtwqEndRegisterWorkQueueWithMMCSS (IRtwqAsyncResult *result, DWORD *taskid)
 
HRESULT WINAPI RtwqBeginUnregisterWorkQueueWithMMCSS (DWORD queue, IRtwqAsyncCallback *callback, IUnknown *state)
 
HRESULT WINAPI RtwqEndUnregisterWorkQueueWithMMCSS (IRtwqAsyncResult *result)
 
HRESULT WINAPI RtwqRegisterPlatformEvents (IRtwqPlatformEvents *events)
 
HRESULT WINAPI RtwqUnregisterPlatformEvents (IRtwqPlatformEvents *events)
 

Variables

static LONG next_item_key
 
static struct queue_handle user_queues [MAX_USER_QUEUE_HANDLES]
 
static struct queue_handlenext_free_user_queue
 
static struct queue_handlenext_unused_user_queue = user_queues
 
static WORD queue_generation
 
static DWORD shared_mt_queue
 
static CRITICAL_SECTION queues_section = { &queues_critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG queues_critsect_debug
 
static LONG platform_lock
 
static CO_MTA_USAGE_COOKIE mta_cookie
 
static const TP_CALLBACK_PRIORITY priorities []
 
static const IRtwqAsyncCallbackVtbl queue_serial_callback_vtbl
 
static struct queue system_queues [SYS_QUEUE_COUNT]
 
static const struct queue_ops pool_queue_ops
 
static const struct queue_ops serial_queue_ops
 
static const IUnknownVtbl work_item_vtbl
 
static const IRtwqAsyncResultVtbl async_result_vtbl
 
static const IRtwqAsyncCallbackVtbl periodic_callback_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file queue.c.

◆ FIRST_USER_QUEUE_HANDLE

#define FIRST_USER_QUEUE_HANDLE   5

Definition at line 29 of file queue.c.

◆ MAX_USER_QUEUE_HANDLES

#define MAX_USER_QUEUE_HANDLES   124

Definition at line 30 of file queue.c.

◆ SCHEDULED_ITEM_KEY_MASK

#define SCHEDULED_ITEM_KEY_MASK   (0x80000000)

Definition at line 33 of file queue.c.

◆ WAIT_ITEM_KEY_MASK

#define WAIT_ITEM_KEY_MASK   (0x82000000)

Definition at line 32 of file queue.c.

Enumeration Type Documentation

◆ rtwq_callback_flags

Enumerator
RTWQ_FAST_IO_PROCESSING_CALLBACK 
RTWQ_SIGNAL_CALLBACK 
RTWQ_BLOCKING_CALLBACK 
RTWQ_REPLY_CALLBACK 
RTWQ_LOCALIZE_REMOTE_CALLBACK 

Definition at line 100 of file queue.c.

101{
103 RTWQ_SIGNAL_CALLBACK = 0x00000002,
104 RTWQ_BLOCKING_CALLBACK = 0x00000004,
105 RTWQ_REPLY_CALLBACK = 0x00000008,
107};
@ RTWQ_REPLY_CALLBACK
Definition: queue.c:105
@ RTWQ_LOCALIZE_REMOTE_CALLBACK
Definition: queue.c:106
@ RTWQ_BLOCKING_CALLBACK
Definition: queue.c:104
@ RTWQ_FAST_IO_PROCESSING_CALLBACK
Definition: queue.c:102
@ RTWQ_SIGNAL_CALLBACK
Definition: queue.c:103

◆ rtwq_callback_queue_id

Enumerator
RTWQ_CALLBACK_QUEUE_UNDEFINED 
RTWQ_CALLBACK_QUEUE_STANDARD 
RTWQ_CALLBACK_QUEUE_RT 
RTWQ_CALLBACK_QUEUE_IO 
RTWQ_CALLBACK_QUEUE_TIMER 
RTWQ_CALLBACK_QUEUE_MULTITHREADED 
RTWQ_CALLBACK_QUEUE_LONG_FUNCTION 
RTWQ_CALLBACK_QUEUE_PRIVATE_MASK 
RTWQ_CALLBACK_QUEUE_ALL 

Definition at line 86 of file queue.c.

87{
90 RTWQ_CALLBACK_QUEUE_RT = 0x00000002,
91 RTWQ_CALLBACK_QUEUE_IO = 0x00000003,
92 RTWQ_CALLBACK_QUEUE_TIMER = 0x00000004,
96 RTWQ_CALLBACK_QUEUE_ALL = 0xffffffff,
97};
@ RTWQ_CALLBACK_QUEUE_MULTITHREADED
Definition: queue.c:93
@ RTWQ_CALLBACK_QUEUE_IO
Definition: queue.c:91
@ RTWQ_CALLBACK_QUEUE_RT
Definition: queue.c:90
@ RTWQ_CALLBACK_QUEUE_LONG_FUNCTION
Definition: queue.c:94
@ RTWQ_CALLBACK_QUEUE_TIMER
Definition: queue.c:92
@ RTWQ_CALLBACK_QUEUE_UNDEFINED
Definition: queue.c:88
@ RTWQ_CALLBACK_QUEUE_PRIVATE_MASK
Definition: queue.c:95
@ RTWQ_CALLBACK_QUEUE_STANDARD
Definition: queue.c:89
@ RTWQ_CALLBACK_QUEUE_ALL
Definition: queue.c:96

◆ system_queue_index

Enumerator
SYS_QUEUE_STANDARD 
SYS_QUEUE_RT 
SYS_QUEUE_IO 
SYS_QUEUE_TIMER 
SYS_QUEUE_MULTITHREADED 
SYS_QUEUE_DO_NOT_USE 
SYS_QUEUE_LONG_FUNCTION 
SYS_QUEUE_COUNT 

Definition at line 109 of file queue.c.

110{
119};
@ SYS_QUEUE_IO
Definition: queue.c:113
@ SYS_QUEUE_COUNT
Definition: queue.c:118
@ SYS_QUEUE_TIMER
Definition: queue.c:114
@ SYS_QUEUE_LONG_FUNCTION
Definition: queue.c:117
@ SYS_QUEUE_RT
Definition: queue.c:112
@ SYS_QUEUE_STANDARD
Definition: queue.c:111
@ SYS_QUEUE_MULTITHREADED
Definition: queue.c:115
@ SYS_QUEUE_DO_NOT_USE
Definition: queue.c:116

◆ work_item_type

Enumerator
WORK_ITEM_WORK 
WORK_ITEM_TIMER 
WORK_ITEM_WAIT 

Definition at line 121 of file queue.c.

122{
126};
@ WORK_ITEM_WORK
Definition: queue.c:123
@ WORK_ITEM_TIMER
Definition: queue.c:124
@ WORK_ITEM_WAIT
Definition: queue.c:125

Function Documentation

◆ alloc_user_queue()

static HRESULT alloc_user_queue ( const struct queue_desc desc,
DWORD queue_id 
)
static

Definition at line 949 of file queue.c.

950{
951 struct queue_handle *entry;
952 struct queue *queue;
953 unsigned int idx;
954
956
957 if (platform_lock <= 0)
958 return RTWQ_E_SHUTDOWN;
959
960 if (!(queue = calloc(1, sizeof(*queue))))
961 return E_OUTOFMEMORY;
962
964
966
968 if (entry)
972 else
973 {
975 free(queue);
976 WARN("Out of user queue handles.\n");
977 return E_OUTOFMEMORY;
978 }
979
980 entry->refcount = 1;
981 entry->obj = queue;
982 if (++queue_generation == 0xffff) queue_generation = 1;
983 entry->generation = queue_generation;
985 *queue_id = (idx << 16) | entry->generation;
986
988
989 return S_OK;
990}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
unsigned int idx
Definition: utils.c:41
#define FIRST_USER_QUEUE_HANDLE
Definition: queue.c:29
static WORD queue_generation
Definition: queue.c:57
static LONG platform_lock
Definition: queue.c:69
#define MAX_USER_QUEUE_HANDLES
Definition: queue.c:30
static struct queue_handle user_queues[MAX_USER_QUEUE_HANDLES]
Definition: queue.c:54
static void init_work_queue(const struct queue_desc *desc, struct queue *queue)
Definition: queue.c:611
static CRITICAL_SECTION queues_section
Definition: queue.c:60
static struct queue_handle * next_free_user_queue
Definition: queue.c:55
static struct queue_handle * next_unused_user_queue
Definition: queue.c:56
#define S_OK
Definition: intsafe.h:52
uint32_t entry
Definition: isohybrid.c:63
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
#define calloc
Definition: rosglue.h:14
Definition: queue.c:179
queue()
Definition: _queue.h:86
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by RtwqAllocateSerialWorkQueue(), RtwqAllocateWorkQueue(), and RtwqLockSharedWorkQueue().

◆ alloc_work_item()

static struct work_item * alloc_work_item ( struct queue queue,
LONG  priority,
IRtwqAsyncResult result 
)
static

Definition at line 589 of file queue.c.

590{
591 RTWQASYNCRESULT *async_result = (RTWQASYNCRESULT *)result;
592 DWORD flags = 0, queue_id = 0;
593 struct work_item *item;
594
595 item = calloc(1, sizeof(*item));
596
597 item->IUnknown_iface.lpVtbl = &work_item_vtbl;
598 item->result = result;
599 IRtwqAsyncResult_AddRef(item->result);
600 item->refcount = 1;
601 item->queue = queue;
602 list_init(&item->entry);
603 item->priority = priority;
604
605 if (SUCCEEDED(IRtwqAsyncCallback_GetParameters(async_result->pCallback, &flags, &queue_id)))
606 item->flags = flags;
607
608 return item;
609}
static void list_init(struct list_entry *head)
Definition: list.h:51
static const IUnknownVtbl work_item_vtbl
Definition: queue.c:582
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static int priority
Definition: timer.c:163
struct queue * queue
Definition: queue.c:135

Referenced by queue_submit_item(), queue_submit_timer(), and queue_submit_wait().

◆ async_result_AddRef()

static ULONG WINAPI async_result_AddRef ( IRtwqAsyncResult iface)
static

Definition at line 1022 of file queue.c.

1023{
1026
1027 TRACE("%p, %lu.\n", iface, refcount);
1028
1029 return refcount;
1030}
#define InterlockedIncrement
Definition: armddk.h:53
static struct async_result * impl_from_IRtwqAsyncResult(IRtwqAsyncResult *iface)
Definition: queue.c:1000
#define TRACE(s)
Definition: solgame.cpp:4
LONG refcount
Definition: queue.c:995
uint32_t ULONG
Definition: typedefs.h:59

◆ async_result_GetObject()

static HRESULT WINAPI async_result_GetObject ( IRtwqAsyncResult iface,
IUnknown **  object 
)
static

Definition at line 1092 of file queue.c.

1093{
1095
1096 TRACE("%p, %p.\n", iface, object);
1097
1098 if (!result->object)
1099 return E_POINTER;
1100
1101 *object = result->object;
1102 IUnknown_AddRef(*object);
1103
1104 return S_OK;
1105}
#define E_POINTER
Definition: winerror.h:3480

◆ async_result_GetState()

static HRESULT WINAPI async_result_GetState ( IRtwqAsyncResult iface,
IUnknown **  state 
)
static

Definition at line 1057 of file queue.c.

1058{
1060
1061 TRACE("%p, %p.\n", iface, state);
1062
1063 if (!result->state)
1064 return E_POINTER;
1065
1066 *state = result->state;
1067 IUnknown_AddRef(*state);
1068
1069 return S_OK;
1070}
static int state
Definition: maze.c:121

◆ async_result_GetStateNoAddRef()

static IUnknown *WINAPI async_result_GetStateNoAddRef ( IRtwqAsyncResult iface)
static

Definition at line 1107 of file queue.c.

1108{
1110
1111 TRACE("%p.\n", iface);
1112
1113 return result->state;
1114}

◆ async_result_GetStatus()

static HRESULT WINAPI async_result_GetStatus ( IRtwqAsyncResult iface)
static

Definition at line 1072 of file queue.c.

1073{
1075
1076 TRACE("%p.\n", iface);
1077
1078 return result->result.hrStatusResult;
1079}

◆ async_result_QueryInterface()

static HRESULT WINAPI async_result_QueryInterface ( IRtwqAsyncResult iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 1005 of file queue.c.

1006{
1007 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
1008
1009 if (IsEqualIID(riid, &IID_IRtwqAsyncResult) ||
1011 {
1012 *obj = iface;
1013 IRtwqAsyncResult_AddRef(iface);
1014 return S_OK;
1015 }
1016
1017 *obj = NULL;
1018 WARN("Unsupported interface %s.\n", debugstr_guid(riid));
1019 return E_NOINTERFACE;
1020}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ async_result_Release()

static ULONG WINAPI async_result_Release ( IRtwqAsyncResult iface)
static

Definition at line 1032 of file queue.c.

1033{
1036
1037 TRACE("%p, %lu.\n", iface, refcount);
1038
1039 if (!refcount)
1040 {
1041 if (result->result.pCallback)
1042 IRtwqAsyncCallback_Release(result->result.pCallback);
1043 if (result->object)
1044 IUnknown_Release(result->object);
1045 if (result->state)
1046 IUnknown_Release(result->state);
1047 if (result->result.hEvent)
1048 CloseHandle(result->result.hEvent);
1049 free(result);
1050
1052 }
1053
1054 return refcount;
1055}
#define InterlockedDecrement
Definition: armddk.h:52
#define CloseHandle
Definition: compat.h:739
HRESULT WINAPI RtwqUnlockPlatform(void)
Definition: queue.c:1174

◆ async_result_SetStatus()

static HRESULT WINAPI async_result_SetStatus ( IRtwqAsyncResult iface,
HRESULT  status 
)
static

Definition at line 1081 of file queue.c.

1082{
1084
1085 TRACE("%p, %#lx.\n", iface, status);
1086
1087 result->result.hrStatusResult = status;
1088
1089 return S_OK;
1090}
Definition: ps.c:97

◆ create_async_result()

static HRESULT create_async_result ( IUnknown object,
IRtwqAsyncCallback callback,
IUnknown state,
IRtwqAsyncResult **  out 
)
static

Definition at line 1128 of file queue.c.

1129{
1130 struct async_result *result;
1131
1132 if (!out)
1133 return E_INVALIDARG;
1134
1135 if (!(result = calloc(1, sizeof(*result))))
1136 return E_OUTOFMEMORY;
1137
1139
1140 result->result.AsyncResult.lpVtbl = &async_result_vtbl;
1141 result->refcount = 1;
1142 result->object = object;
1143 if (result->object)
1144 IUnknown_AddRef(result->object);
1145 result->result.pCallback = callback;
1146 if (result->result.pCallback)
1147 IRtwqAsyncCallback_AddRef(result->result.pCallback);
1148 result->state = state;
1149 if (result->state)
1150 IUnknown_AddRef(result->state);
1151
1152 *out = &result->result.AsyncResult;
1153
1154 TRACE("Created async result object %p.\n", *out);
1155
1156 return S_OK;
1157}
#define E_INVALIDARG
Definition: ddrawi.h:101
static const IRtwqAsyncResultVtbl async_result_vtbl
Definition: queue.c:1116
HRESULT WINAPI RtwqLockPlatform(void)
Definition: queue.c:1167
static IPrintDialogCallback callback
Definition: printdlg.c:326
IUnknown * object
Definition: queue.c:996
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by RtwqAddPeriodicCallback(), and RtwqCreateAsyncResult().

◆ create_periodic_callback_obj()

static HRESULT create_periodic_callback_obj ( RTWQPERIODICCALLBACK  callback,
IRtwqAsyncCallback **  out 
)
static

Definition at line 1362 of file queue.c.

1363{
1364 struct periodic_callback *object;
1365
1366 if (!(object = calloc(1, sizeof(*object))))
1367 return E_OUTOFMEMORY;
1368
1369 object->IRtwqAsyncCallback_iface.lpVtbl = &periodic_callback_vtbl;
1370 object->refcount = 1;
1371 object->callback = callback;
1372
1373 *out = &object->IRtwqAsyncCallback_iface;
1374
1375 return S_OK;
1376}
static const IRtwqAsyncCallbackVtbl periodic_callback_vtbl
Definition: queue.c:1353

Referenced by RtwqAddPeriodicCallback().

◆ generate_item_key()

static RTWQWORKITEM_KEY generate_item_key ( DWORD  mask)
static

Definition at line 42 of file queue.c.

43{
45}
static LONG next_item_key
Definition: queue.c:35
static RTWQWORKITEM_KEY get_item_key(DWORD mask, DWORD key)
Definition: queue.c:37
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by queue_mark_item_pending().

◆ get_item_key()

static RTWQWORKITEM_KEY get_item_key ( DWORD  mask,
DWORD  key 
)
static

Definition at line 37 of file queue.c.

38{
39 return ((RTWQWORKITEM_KEY)mask << 32) | key;
40}
unsigned __int64 RTWQWORKITEM_KEY
Definition: rtworkq.idl:28
Definition: copy.c:22

Referenced by generate_item_key(), and RtwqRemovePeriodicCallback().

◆ get_queue_obj()

static struct queue_handle * get_queue_obj ( DWORD  handle)
static

Definition at line 72 of file queue.c.

73{
74 unsigned int idx = HIWORD(handle) - FIRST_USER_QUEUE_HANDLE;
75
76 if (idx < MAX_USER_QUEUE_HANDLES && user_queues[idx].refcount)
77 {
79 return &user_queues[idx];
80 }
81
82 return NULL;
83}
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2996
#define LOWORD(l)
Definition: pedump.c:82
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by grab_queue(), lock_user_queue(), and unlock_user_queue().

◆ get_system_queue()

static struct queue * get_system_queue ( DWORD  queue_id)
static

Definition at line 297 of file queue.c.

298{
299 switch (queue_id)
300 {
307 return &system_queues[queue_id - 1];
308 default:
309 return NULL;
310 }
311}
static struct queue system_queues[SYS_QUEUE_COUNT]
Definition: queue.c:295

Referenced by grab_queue().

◆ grab_queue()

static HRESULT grab_queue ( DWORD  queue_id,
struct queue **  ret 
)
static

Definition at line 623 of file queue.c.

624{
625 struct queue *queue = get_system_queue(queue_id);
626 RTWQ_WORKQUEUE_TYPE queue_type;
627 struct queue_handle *entry;
628
629 *ret = NULL;
630
632 return RTWQ_E_SHUTDOWN;
633
634 if (queue && queue->pool)
635 {
636 *ret = queue;
637 return S_OK;
638 }
639 else if (queue)
640 {
641 struct queue_desc desc;
642
644 switch (queue_id)
645 {
650 break;
651 default:
653 }
654
655 desc.queue_type = queue_type;
656 desc.ops = &pool_queue_ops;
657 desc.target_queue = 0;
660 *ret = queue;
661 return S_OK;
662 }
663
664 /* Handles user queues. */
665 if ((entry = get_queue_obj(queue_id)))
666 *ret = entry->obj;
667
668 return *ret ? S_OK : RTWQ_E_INVALID_WORKQUEUE;
669}
static struct queue_handle * get_queue_obj(DWORD handle)
Definition: queue.c:72
static const struct queue_ops pool_queue_ops
Definition: queue.c:405
static struct queue * get_system_queue(DWORD queue_id)
Definition: queue.c:297
return ret
Definition: mutex.c:147
RTWQ_WORKQUEUE_TYPE
Definition: rtworkq.idl:22
@ RTWQ_MULTITHREADED_WORKQUEUE
Definition: rtworkq.idl:25
@ RTWQ_STANDARD_WORKQUEUE
Definition: rtworkq.idl:23
RTWQ_WORKQUEUE_TYPE queue_type
Definition: queue.c:173
TP_POOL * pool
Definition: queue.c:182

Referenced by queue_put_work_item(), RtwqAddPeriodicCallback(), RtwqCancelWorkItem(), RtwqPutWaitingWorkItem(), RtwqRemovePeriodicCallback(), RtwqSetLongRunning(), schedule_work_item(), serial_queue_finalization_callback(), and serial_queue_submit().

◆ impl_from_IRtwqAsyncCallback()

static struct periodic_callback * impl_from_IRtwqAsyncCallback ( IRtwqAsyncCallback iface)
static

Definition at line 1290 of file queue.c.

1291{
1292 return CONTAINING_RECORD(iface, struct periodic_callback, IRtwqAsyncCallback_iface);
1293}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by periodic_callback_AddRef(), periodic_callback_Invoke(), and periodic_callback_Release().

◆ impl_from_IRtwqAsyncResult()

static struct async_result * impl_from_IRtwqAsyncResult ( IRtwqAsyncResult iface)
static

◆ init_system_queues()

static void init_system_queues ( void  )
static

Definition at line 1181 of file queue.c.

1182{
1183 struct queue_desc desc;
1184 HRESULT hr;
1185
1186 /* Always initialize standard queue, keep the rest lazy. */
1187
1189
1191 {
1193 return;
1194 }
1195
1197 WARN("Failed to initialize MTA, hr %#lx.\n", hr);
1198
1199 desc.queue_type = RTWQ_STANDARD_WORKQUEUE;
1200 desc.ops = &pool_queue_ops;
1201 desc.target_queue = 0;
1203
1205}
HRESULT hr
Definition: delayimp.cpp:582
HRESULT WINAPI CoIncrementMTAUsage(CO_MTA_USAGE_COOKIE *cookie)
Definition: combase.c:2907
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by RtwqStartup().

◆ init_work_queue()

static void init_work_queue ( const struct queue_desc desc,
struct queue queue 
)
static

Definition at line 611 of file queue.c.

612{
613 assert(desc->ops != NULL);
614
615 queue->ops = desc->ops;
616 if (SUCCEEDED(queue->ops->init(desc, queue)))
617 {
620 }
621}
#define assert(_expr)
Definition: assert.h:32
struct list pending_items
Definition: queue.c:185
CRITICAL_SECTION cs
Definition: queue.c:184
const struct queue_ops * ops
Definition: queue.c:181
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:687

Referenced by alloc_user_queue(), grab_queue(), and init_system_queues().

◆ invoke_async_callback()

static HRESULT invoke_async_callback ( IRtwqAsyncResult result)
static

Definition at line 714 of file queue.c.

715{
716 RTWQASYNCRESULT *result_data = (RTWQASYNCRESULT *)result;
718 HRESULT hr;
719
720 if (FAILED(IRtwqAsyncCallback_GetParameters(result_data->pCallback, &flags, &queue)))
722
725
727
729
730 return hr;
731}
static HRESULT queue_put_work_item(DWORD queue_id, LONG priority, IRtwqAsyncResult *result)
Definition: queue.c:703
static HRESULT unlock_user_queue(DWORD queue)
Definition: queue.c:213
static HRESULT lock_user_queue(DWORD queue)
Definition: queue.c:194

Referenced by periodic_item_callback(), queue_cancel_item(), RtwqInvokeCallback(), scheduled_item_callback(), scheduled_item_cancelable_callback(), waiting_item_callback(), and waiting_item_cancelable_callback().

◆ lock_user_queue()

static HRESULT lock_user_queue ( DWORD  queue)
static

Definition at line 194 of file queue.c.

195{
196 HRESULT hr = RTWQ_E_INVALID_WORKQUEUE;
197 struct queue_handle *entry;
198
200 return S_OK;
201
204 if (entry && entry->refcount)
205 {
206 entry->refcount++;
207 hr = S_OK;
208 }
210 return hr;
211}

Referenced by invoke_async_callback(), RtwqLockSharedWorkQueue(), RtwqLockWorkQueue(), RtwqSetLongRunning(), and serial_queue_init().

◆ periodic_callback_AddRef()

static ULONG WINAPI periodic_callback_AddRef ( IRtwqAsyncCallback iface)
static

Definition at line 1309 of file queue.c.

1310{
1313
1314 TRACE("%p, %lu.\n", iface, refcount);
1315
1316 return refcount;
1317}
static struct periodic_callback * impl_from_IRtwqAsyncCallback(IRtwqAsyncCallback *iface)
Definition: queue.c:1290

◆ periodic_callback_GetParameters()

static HRESULT WINAPI periodic_callback_GetParameters ( IRtwqAsyncCallback iface,
DWORD flags,
DWORD queue 
)
static

Definition at line 1332 of file queue.c.

1333{
1334 return E_NOTIMPL;
1335}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ periodic_callback_Invoke()

static HRESULT WINAPI periodic_callback_Invoke ( IRtwqAsyncCallback iface,
IRtwqAsyncResult result 
)
static

Definition at line 1337 of file queue.c.

1338{
1341
1342 if (FAILED(IRtwqAsyncResult_GetObject(result, &context)))
1343 WARN("Expected object to be set for result object.\n");
1344
1345 callback->callback(context);
1346
1347 if (context)
1348 IUnknown_Release(context);
1349
1350 return S_OK;
1351}
Definition: http.c:7252

◆ periodic_callback_QueryInterface()

static HRESULT WINAPI periodic_callback_QueryInterface ( IRtwqAsyncCallback iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 1295 of file queue.c.

1296{
1297 if (IsEqualIID(riid, &IID_IRtwqAsyncCallback) ||
1299 {
1300 *obj = iface;
1301 IRtwqAsyncCallback_AddRef(iface);
1302 return S_OK;
1303 }
1304
1305 *obj = NULL;
1306 return E_NOINTERFACE;
1307}

◆ periodic_callback_Release()

static ULONG WINAPI periodic_callback_Release ( IRtwqAsyncCallback iface)
static

Definition at line 1319 of file queue.c.

1320{
1323
1324 TRACE("%p, %lu.\n", iface, refcount);
1325
1326 if (!refcount)
1327 free(callback);
1328
1329 return refcount;
1330}

◆ periodic_item_callback()

static void CALLBACK periodic_item_callback ( TP_CALLBACK_INSTANCE instance,
void context,
TP_TIMER timer 
)
static

Definition at line 800 of file queue.c.

801{
802 struct work_item *item = context;
803
804 IUnknown_AddRef(&item->IUnknown_iface);
805
807
808 IUnknown_Release(&item->IUnknown_iface);
809}
static HRESULT invoke_async_callback(IRtwqAsyncResult *result)
Definition: queue.c:714

Referenced by queue_submit_timer().

◆ pool_queue_init()

static HRESULT pool_queue_init ( const struct queue_desc desc,
struct queue queue 
)
static

Definition at line 319 of file queue.c.

320{
322 unsigned int max_thread, i;
323
325
326 memset(&env, 0, sizeof(env));
327 env.Version = 3;
328 env.Size = sizeof(env);
329 env.Pool = queue->pool;
330 env.CleanupGroup = CreateThreadpoolCleanupGroup();
331 env.CleanupGroupCancelCallback = standard_queue_cleanup_callback;
332 env.CallbackPriority = TP_CALLBACK_PRIORITY_NORMAL;
333 for (i = 0; i < ARRAY_SIZE(queue->envs); ++i)
334 {
335 queue->envs[i] = env;
337 }
340
341 max_thread = (desc->queue_type == RTWQ_STANDARD_WORKQUEUE || desc->queue_type == RTWQ_WINDOW_WORKQUEUE) ? 1 : 4;
342
345
346 if (desc->queue_type == RTWQ_WINDOW_WORKQUEUE)
347 FIXME("RTWQ_WINDOW_WORKQUEUE is not supported.\n");
348
349 return S_OK;
350}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:171
PTP_POOL WINAPI DECLSPEC_HOTPATCH CreateThreadpool(void *reserved)
Definition: threadpool.c:132
PTP_CLEANUP_GROUP WINAPI DECLSPEC_HOTPATCH CreateThreadpoolCleanupGroup(void)
Definition: threadpool.c:115
static void CALLBACK standard_queue_cleanup_callback(void *object_data, void *group_data)
Definition: queue.c:315
const GLuint const GLclampf * priorities
Definition: glext.h:8103
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ RTWQ_WINDOW_WORKQUEUE
Definition: rtworkq.idl:24
#define memset(x, y, z)
Definition: compat.h:39
TP_CALLBACK_PRIORITY CallbackPriority
Definition: winnt_old.h:4818
TP_CALLBACK_ENVIRON_V3 envs[ARRAY_SIZE(priorities)]
Definition: queue.c:183
WINBASEAPI BOOL WINAPI SetThreadpoolThreadMinimum(_Inout_ PTP_POOL ptpp, _In_ DWORD cthrdMic)
WINBASEAPI VOID WINAPI SetThreadpoolThreadMaximum(_Inout_ PTP_POOL ptpp, _In_ DWORD cthrdMost)
@ TP_CALLBACK_PRIORITY_NORMAL
Definition: winnt_old.h:4766

◆ pool_queue_shutdown()

static BOOL pool_queue_shutdown ( struct queue queue)
static

Definition at line 352 of file queue.c.

353{
354 if (!queue->pool)
355 return FALSE;
356
359 queue->pool = NULL;
360
361 return TRUE;
362}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PTP_CLEANUP_GROUP CleanupGroup
Definition: winnt_old.h:4805
WINBASEAPI VOID WINAPI CloseThreadpool(_Inout_ PTP_POOL ptpp)
WINBASEAPI VOID WINAPI CloseThreadpoolCleanupGroupMembers(_Inout_ PTP_CLEANUP_GROUP ptpcg, _In_ BOOL fCancelPendingCallbacks, _Inout_opt_ PVOID pvCleanupContext)

◆ pool_queue_submit()

static void pool_queue_submit ( struct queue queue,
struct work_item item 
)
static

Definition at line 380 of file queue.c.

381{
382 TP_CALLBACK_PRIORITY callback_priority;
384
385 if (item->priority == 0)
386 callback_priority = TP_CALLBACK_PRIORITY_NORMAL;
387 else if (item->priority < 0)
388 callback_priority = TP_CALLBACK_PRIORITY_LOW;
389 else
390 callback_priority = TP_CALLBACK_PRIORITY_HIGH;
391
392 env = queue->envs[callback_priority];
393 env.FinalizationCallback = item->finalization_callback;
394 /* Worker pool callback will release one reference. Grab one more to keep object alive when
395 we need finalization callback. */
396 if (item->finalization_callback)
397 IUnknown_AddRef(&item->IUnknown_iface);
400 SubmitThreadpoolWork(item->u.work_object);
401
402 TRACE("dispatched %p.\n", item->result);
403}
PTP_WORK WINAPI DECLSPEC_HOTPATCH CreateThreadpoolWork(PTP_WORK_CALLBACK callback, PVOID userdata, TP_CALLBACK_ENVIRON *environment)
Definition: threadpool.c:82
static void CALLBACK standard_queue_worker(TP_CALLBACK_INSTANCE *instance, void *context, TP_WORK *work)
Definition: queue.c:364
uacpi_u8 type
Definition: interpreter.c:38
WINBASEAPI VOID WINAPI SubmitThreadpoolWork(_Inout_ PTP_WORK pwk)
@ TP_CALLBACK_PRIORITY_HIGH
Definition: winnt_old.h:4765
@ TP_CALLBACK_PRIORITY_LOW
Definition: winnt_old.h:4767
enum _TP_CALLBACK_PRIORITY TP_CALLBACK_PRIORITY

◆ queue_cancel_item()

static HRESULT queue_cancel_item ( struct queue queue,
RTWQWORKITEM_KEY  key 
)
static

Definition at line 884 of file queue.c.

885{
886 TP_WAIT *wait_object;
887 TP_TIMER *timer_object;
888 struct work_item *item;
889
892 {
893 if (item->key == key)
894 {
895 /* We can't immediately release the item here, because the callback could already be
896 * running somewhere else. And if we release it here, the callback will access freed memory.
897 * So instead we have to make sure the callback is really stopped, or has really finished
898 * running before we do that. And we can't do that in this critical section, which would be a
899 * deadlock. So we first keep an extra reference to it, then leave the critical section to
900 * wait for the thread-pool objects, finally we re-enter critical section to release it. */
901 key >>= 32;
902 IUnknown_AddRef(&item->IUnknown_iface);
904 {
905 wait_object = item->u.wait_object;
906 item->u.wait_object = NULL;
908
912 }
914 {
915 timer_object = item->u.timer_object;
916 item->u.timer_object = NULL;
918
922 }
923 else
924 {
925 WARN("Unknown item key mask %#I64x.\n", key);
927 }
928
930 {
931 /* This means the callback wasn't run during our wait, so we can invoke the
932 * callback with a canceled status, and release the work item. */
934 {
935 IRtwqAsyncResult_SetStatus(item->result, RTWQ_E_OPERATION_CANCELLED);
937 }
938 IUnknown_Release(&item->IUnknown_iface);
939 }
940 IUnknown_Release(&item->IUnknown_iface);
941 return S_OK;
942 }
943 }
945
946 return RTWQ_E_NOT_FOUND;
947}
static BOOL queue_release_pending_item(struct work_item *item)
Definition: queue.c:735
#define WAIT_ITEM_KEY_MASK
Definition: queue.c:32
#define SCHEDULED_ITEM_KEY_MASK
Definition: queue.c:33
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
TP_WAIT * wait_object
Definition: queue.c:144
TP_TIMER * timer_object
Definition: queue.c:145
WINBASEAPI VOID WINAPI WaitForThreadpoolTimerCallbacks(_Inout_ PTP_TIMER pti, _In_ BOOL fCancelPendingCallbacks)
WINBASEAPI VOID WINAPI CloseThreadpoolTimer(_Inout_ PTP_TIMER pti)
WINBASEAPI VOID WINAPI SetThreadpoolTimer(_Inout_ PTP_TIMER pti, _In_opt_ PFILETIME pftDueTime, _In_ DWORD msPeriod, _In_opt_ DWORD msWindowLength)
WINBASEAPI VOID WINAPI SetThreadpoolWait(_Inout_ PTP_WAIT pwa, _In_opt_ HANDLE h, _In_opt_ PFILETIME pftTimeout)
WINBASEAPI VOID WINAPI CloseThreadpoolWait(_Inout_ PTP_WAIT pwa)
WINBASEAPI VOID WINAPI WaitForThreadpoolWaitCallbacks(_Inout_ PTP_WAIT pwa, _In_ BOOL fCancelPendingCallbacks)
struct _TP_WAIT TP_WAIT
Definition: winnt_old.h:4758
struct _TP_TIMER TP_TIMER
Definition: winnt_old.h:4757

Referenced by RtwqCancelWorkItem(), and RtwqRemovePeriodicCallback().

◆ queue_impl_from_IRtwqAsyncCallback()

static struct queue * queue_impl_from_IRtwqAsyncCallback ( IRtwqAsyncCallback iface)
static

Definition at line 239 of file queue.c.

240{
241 return CONTAINING_RECORD(iface, struct queue, IRtwqAsyncCallback_iface);
242}

Referenced by queue_serial_callback_GetParameters().

◆ queue_mark_item_pending()

static void queue_mark_item_pending ( DWORD  mask,
struct work_item item,
RTWQWORKITEM_KEY key 
)
static

Definition at line 811 of file queue.c.

812{
814 item->key = *key;
815
816 EnterCriticalSection(&item->queue->cs);
817 list_add_tail(&item->queue->pending_items, &item->entry);
818 IUnknown_AddRef(&item->IUnknown_iface);
819 LeaveCriticalSection(&item->queue->cs);
820}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static RTWQWORKITEM_KEY generate_item_key(DWORD mask)
Definition: queue.c:42

Referenced by queue_submit_timer(), and queue_submit_wait().

◆ queue_put_work_item()

static HRESULT queue_put_work_item ( DWORD  queue_id,
LONG  priority,
IRtwqAsyncResult result 
)
static

Definition at line 703 of file queue.c.

704{
705 struct queue *queue;
706 HRESULT hr;
707
708 if (FAILED(hr = grab_queue(queue_id, &queue)))
709 return hr;
710
712}
static HRESULT grab_queue(DWORD queue_id, struct queue **ret)
Definition: queue.c:623
static HRESULT queue_submit_item(struct queue *queue, LONG priority, IRtwqAsyncResult *result)
Definition: queue.c:691

Referenced by invoke_async_callback(), and RtwqPutWorkItem().

◆ queue_release_pending_item()

static BOOL queue_release_pending_item ( struct work_item item)
static

Definition at line 735 of file queue.c.

736{
737 struct queue *queue = item->queue;
738 BOOL ret = FALSE;
739
741 if (item->key)
742 {
743 list_remove(&item->entry);
744 ret = TRUE;
745 item->key = 0;
746 IUnknown_Release(&item->IUnknown_iface);
747 }
749 return ret;
750}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by queue_cancel_item(), scheduled_item_cancelable_callback(), and waiting_item_cancelable_callback().

◆ queue_serial_callback_AddRef()

static ULONG WINAPI queue_serial_callback_AddRef ( IRtwqAsyncCallback iface)
static

Definition at line 258 of file queue.c.

259{
260 return 2;
261}

◆ queue_serial_callback_GetParameters()

static HRESULT WINAPI queue_serial_callback_GetParameters ( IRtwqAsyncCallback iface,
DWORD flags,
DWORD queue_id 
)
static

Definition at line 268 of file queue.c.

269{
271
272 *flags = 0;
273 *queue_id = queue->id;
274
275 return S_OK;
276}
static struct queue * queue_impl_from_IRtwqAsyncCallback(IRtwqAsyncCallback *iface)
Definition: queue.c:239
DWORD id
Definition: queue.c:186

◆ queue_serial_callback_Invoke()

static HRESULT WINAPI queue_serial_callback_Invoke ( IRtwqAsyncCallback iface,
IRtwqAsyncResult result 
)
static

Definition at line 278 of file queue.c.

279{
280 /* Reply callback won't be called in a regular way, pending items and chained queues will make it
281 unnecessary complicated to reach actual work queue that's able to execute this item. Instead
282 serial queues are cleaned up right away on submit(). */
283 return S_OK;
284}

◆ queue_serial_callback_QueryInterface()

static HRESULT WINAPI queue_serial_callback_QueryInterface ( IRtwqAsyncCallback iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 244 of file queue.c.

245{
246 if (IsEqualIID(riid, &IID_IRtwqAsyncCallback) ||
248 {
249 *obj = iface;
250 IRtwqAsyncCallback_AddRef(iface);
251 return S_OK;
252 }
253
254 *obj = NULL;
255 return E_NOINTERFACE;
256}

◆ queue_serial_callback_Release()

static ULONG WINAPI queue_serial_callback_Release ( IRtwqAsyncCallback iface)
static

Definition at line 263 of file queue.c.

264{
265 return 1;
266}

◆ queue_submit_item()

static HRESULT queue_submit_item ( struct queue queue,
LONG  priority,
IRtwqAsyncResult result 
)
static

Definition at line 691 of file queue.c.

692{
693 struct work_item *item;
694
696 return E_OUTOFMEMORY;
697
698 queue->ops->submit(queue, item);
699
700 return S_OK;
701}
static struct work_item * alloc_work_item(struct queue *queue, LONG priority, IRtwqAsyncResult *result)
Definition: queue.c:589

Referenced by queue_put_work_item().

◆ queue_submit_timer()

static HRESULT queue_submit_timer ( struct queue queue,
IRtwqAsyncResult result,
INT64  timeout,
DWORD  period,
RTWQWORKITEM_KEY key 
)
static

Definition at line 849 of file queue.c.

851{
853 struct work_item *item;
854 FILETIME filetime;
856
857 if (!(item = alloc_work_item(queue, 0, result)))
858 return E_OUTOFMEMORY;
859
860 if (key)
861 {
863 }
864
865 if (period)
867 else
869
870 t.QuadPart = timeout * 1000 * 10;
871 filetime.dwLowDateTime = t.u.LowPart;
872 filetime.dwHighDateTime = t.u.HighPart;
873
874 item->u.timer_object = CreateThreadpoolTimer(callback, item,
877 SetThreadpoolTimer(item->u.timer_object, &filetime, period, 0);
878
879 TRACE("dispatched %p.\n", result);
880
881 return S_OK;
882}
PTP_TIMER WINAPI DECLSPEC_HOTPATCH CreateThreadpoolTimer(PTP_TIMER_CALLBACK callback, PVOID userdata, TP_CALLBACK_ENVIRON *environment)
Definition: threadpool.c:20
static void queue_mark_item_pending(DWORD mask, struct work_item *item, RTWQWORKITEM_KEY *key)
Definition: queue.c:811
static void CALLBACK scheduled_item_callback(TP_CALLBACK_INSTANCE *instance, void *context, TP_TIMER *timer)
Definition: queue.c:777
static void CALLBACK scheduled_item_cancelable_callback(TP_CALLBACK_INSTANCE *instance, void *context, TP_TIMER *timer)
Definition: queue.c:788
static void CALLBACK periodic_item_callback(TP_CALLBACK_INSTANCE *instance, void *context, TP_TIMER *timer)
Definition: queue.c:800
GLdouble GLdouble t
Definition: gl.h:2047
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: dhcpd.h:248
VOID(NTAPI * PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE, PVOID, PTP_TIMER)
Definition: winnt_old.h:4796

Referenced by RtwqAddPeriodicCallback(), and schedule_work_item().

◆ queue_submit_wait()

static HRESULT queue_submit_wait ( struct queue queue,
HANDLE  event,
LONG  priority,
IRtwqAsyncResult result,
RTWQWORKITEM_KEY key 
)
static

Definition at line 822 of file queue.c.

824{
826 struct work_item *item;
827
829 return E_OUTOFMEMORY;
830
831 if (key)
832 {
835 }
836 else
838
839 item->u.wait_object = CreateThreadpoolWait(callback, item,
842 SetThreadpoolWait(item->u.wait_object, event, NULL);
843
844 TRACE("dispatched %p.\n", result);
845
846 return S_OK;
847}
PTP_WAIT WINAPI DECLSPEC_HOTPATCH CreateThreadpoolWait(PTP_WAIT_CALLBACK callback, PVOID userdata, TP_CALLBACK_ENVIRON *environment)
Definition: threadpool.c:63
static void CALLBACK waiting_item_cancelable_callback(TP_CALLBACK_INSTANCE *instance, void *context, TP_WAIT *wait, TP_WAIT_RESULT wait_result)
Definition: queue.c:764
static void CALLBACK waiting_item_callback(TP_CALLBACK_INSTANCE *instance, void *context, TP_WAIT *wait, TP_WAIT_RESULT wait_result)
Definition: queue.c:752
struct _cl_event * event
Definition: glext.h:7739
VOID(NTAPI * PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE, PVOID, PTP_WAIT, TP_WAIT_RESULT)
Definition: winnt_old.h:4797

Referenced by RtwqPutWaitingWorkItem().

◆ RtwqAddPeriodicCallback()

HRESULT WINAPI RtwqAddPeriodicCallback ( RTWQPERIODICCALLBACK  callback,
IUnknown context,
DWORD key 
)

Definition at line 1378 of file queue.c.

1379{
1381 RTWQWORKITEM_KEY workitem_key;
1383 struct queue *queue;
1384 HRESULT hr;
1385
1386 TRACE("%p, %p, %p.\n", callback, context, key);
1387
1389 return hr;
1390
1392 return hr;
1393
1395 IRtwqAsyncCallback_Release(periodic_callback);
1396 if (FAILED(hr))
1397 return hr;
1398
1399 /* Same period MFGetTimerPeriodicity() returns. */
1400 hr = queue_submit_timer(queue, result, 0, 10, key ? &workitem_key : NULL);
1401
1402 IRtwqAsyncResult_Release(result);
1403
1404 if (key)
1405 *key = workitem_key;
1406
1407 return S_OK;
1408}
static HRESULT create_periodic_callback_obj(RTWQPERIODICCALLBACK callback, IRtwqAsyncCallback **out)
Definition: queue.c:1362
static HRESULT create_async_result(IUnknown *object, IRtwqAsyncCallback *callback, IUnknown *state, IRtwqAsyncResult **out)
Definition: queue.c:1128
static HRESULT queue_submit_timer(struct queue *queue, IRtwqAsyncResult *result, INT64 timeout, DWORD period, RTWQWORKITEM_KEY *key)
Definition: queue.c:849

◆ RtwqAllocateSerialWorkQueue()

HRESULT WINAPI RtwqAllocateSerialWorkQueue ( DWORD  target_queue,
DWORD queue 
)

Definition at line 1553 of file queue.c.

1554{
1555 struct queue_desc desc;
1556
1557 TRACE("%#lx, %p.\n", target_queue, queue);
1558
1559 desc.queue_type = RTWQ_STANDARD_WORKQUEUE;
1560 desc.ops = &serial_queue_ops;
1561 desc.target_queue = target_queue;
1562 return alloc_user_queue(&desc, queue);
1563}
static HRESULT alloc_user_queue(const struct queue_desc *desc, DWORD *queue_id)
Definition: queue.c:949
static const struct queue_ops serial_queue_ops
Definition: queue.c:528
DWORD target_queue
Definition: queue.c:175

◆ RtwqAllocateWorkQueue()

HRESULT WINAPI RtwqAllocateWorkQueue ( RTWQ_WORKQUEUE_TYPE  queue_type,
DWORD queue 
)

Definition at line 1450 of file queue.c.

1451{
1452 struct queue_desc desc;
1453
1454 TRACE("%d, %p.\n", queue_type, queue);
1455
1456 desc.queue_type = queue_type;
1457 desc.ops = &pool_queue_ops;
1458 desc.target_queue = 0;
1459 return alloc_user_queue(&desc, queue);
1460}

◆ RtwqBeginRegisterWorkQueueWithMMCSS()

HRESULT WINAPI RtwqBeginRegisterWorkQueueWithMMCSS ( DWORD  queue,
const WCHAR class,
DWORD  taskid,
LONG  priority,
IRtwqAsyncCallback callback,
IUnknown state 
)

Definition at line 1614 of file queue.c.

1616{
1617 FIXME("%#lx, %s, %lu, %ld, %p, %p.\n", queue, debugstr_w(class), taskid, priority, callback, state);
1618
1619 return E_NOTIMPL;
1620}
#define debugstr_w
Definition: kernel32.h:32

◆ RtwqBeginUnregisterWorkQueueWithMMCSS()

HRESULT WINAPI RtwqBeginUnregisterWorkQueueWithMMCSS ( DWORD  queue,
IRtwqAsyncCallback callback,
IUnknown state 
)

Definition at line 1629 of file queue.c.

1630{
1631 FIXME("%#lx, %p, %p.\n", queue, callback, state);
1632
1633 return E_NOTIMPL;
1634}

◆ RtwqCancelDeadline()

HRESULT WINAPI RtwqCancelDeadline ( HANDLE  request)

Definition at line 1546 of file queue.c.

1547{
1548 FIXME("%p.\n", request);
1549
1550 return E_NOTIMPL;
1551}
Definition: tftpd.h:86

◆ RtwqCancelWorkItem()

HRESULT WINAPI RtwqCancelWorkItem ( RTWQWORKITEM_KEY  key)

Definition at line 1423 of file queue.c.

1424{
1425 struct queue *queue;
1426 HRESULT hr;
1427
1428 TRACE("%s.\n", wine_dbgstr_longlong(key));
1429
1431 return hr;
1432
1433 return queue_cancel_item(queue, key);
1434}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static HRESULT queue_cancel_item(struct queue *queue, RTWQWORKITEM_KEY key)
Definition: queue.c:884

◆ RtwqCreateAsyncResult()

HRESULT WINAPI RtwqCreateAsyncResult ( IUnknown object,
IRtwqAsyncCallback callback,
IUnknown state,
IRtwqAsyncResult **  out 
)

Definition at line 1159 of file queue.c.

1161{
1162 TRACE("%p, %p, %p, %p.\n", object, callback, state, out);
1163
1164 return create_async_result(object, callback, state, out);
1165}

Referenced by serial_queue_submit().

◆ RtwqEndRegisterWorkQueueWithMMCSS()

HRESULT WINAPI RtwqEndRegisterWorkQueueWithMMCSS ( IRtwqAsyncResult result,
DWORD taskid 
)

Definition at line 1622 of file queue.c.

1623{
1624 FIXME("%p, %p.\n", result, taskid);
1625
1626 return E_NOTIMPL;
1627}

◆ RtwqEndUnregisterWorkQueueWithMMCSS()

HRESULT WINAPI RtwqEndUnregisterWorkQueueWithMMCSS ( IRtwqAsyncResult result)

Definition at line 1636 of file queue.c.

1637{
1638 FIXME("%p.\n", result);
1639
1640 return E_NOTIMPL;
1641}

◆ RtwqGetWorkQueueMMCSSClass()

HRESULT WINAPI RtwqGetWorkQueueMMCSSClass ( DWORD  queue,
WCHAR class,
DWORD length 
)

Definition at line 1579 of file queue.c.

1580{
1581 FIXME("%#lx, %p, %p.\n", queue, class, length);
1582
1583 return E_NOTIMPL;
1584}
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

◆ RtwqGetWorkQueueMMCSSPriority()

HRESULT WINAPI RtwqGetWorkQueueMMCSSPriority ( DWORD  queue,
LONG priority 
)

Definition at line 1593 of file queue.c.

1594{
1595 FIXME("%#lx, %p.\n", queue, priority);
1596
1597 return E_NOTIMPL;
1598}

◆ RtwqGetWorkQueueMMCSSTaskId()

HRESULT WINAPI RtwqGetWorkQueueMMCSSTaskId ( DWORD  queue,
DWORD taskid 
)

Definition at line 1586 of file queue.c.

1587{
1588 FIXME("%#lx, %p.\n", queue, taskid);
1589
1590 return E_NOTIMPL;
1591}

◆ RtwqInvokeCallback()

HRESULT WINAPI RtwqInvokeCallback ( IRtwqAsyncResult result)

Definition at line 1436 of file queue.c.

1437{
1438 TRACE("%p.\n", result);
1439
1441}

◆ RtwqJoinWorkQueue()

HRESULT WINAPI RtwqJoinWorkQueue ( DWORD  queue,
HANDLE  hFile,
HANDLE cookie 
)

Definition at line 1565 of file queue.c.

1566{
1567 FIXME("%#lx, %p, %p.\n", queue, hFile, cookie);
1568
1569 return E_NOTIMPL;
1570}
_In_ HANDLE hFile
Definition: mswsock.h:90
Definition: cookie.c:34

◆ RtwqLockPlatform()

HRESULT WINAPI RtwqLockPlatform ( void  )

Definition at line 1167 of file queue.c.

1168{
1170
1171 return S_OK;
1172}

Referenced by create_async_result().

◆ RtwqLockSharedWorkQueue()

HRESULT WINAPI RtwqLockSharedWorkQueue ( const WCHAR usageclass,
LONG  priority,
DWORD taskid,
DWORD queue 
)

Definition at line 1497 of file queue.c.

1498{
1499 struct queue_desc desc;
1500 HRESULT hr;
1501
1502 TRACE("%s, %ld, %p, %p.\n", debugstr_w(usageclass), priority, taskid, queue);
1503
1504 if (!usageclass)
1505 return E_POINTER;
1506
1507 if (!*usageclass && taskid)
1508 return E_INVALIDARG;
1509
1510 if (*usageclass)
1511 FIXME("Class name is ignored.\n");
1512
1514
1515 if (shared_mt_queue)
1517 else
1518 {
1520 desc.ops = &pool_queue_ops;
1521 desc.target_queue = 0;
1523 }
1524
1526
1528
1529 return hr;
1530}
static DWORD shared_mt_queue
Definition: queue.c:58

◆ RtwqLockWorkQueue()

HRESULT WINAPI RtwqLockWorkQueue ( DWORD  queue)

Definition at line 1462 of file queue.c.

1463{
1464 TRACE("%#lx.\n", queue);
1465
1466 return lock_user_queue(queue);
1467}

◆ RtwqPutWaitingWorkItem()

HRESULT WINAPI RtwqPutWaitingWorkItem ( HANDLE  event,
LONG  priority,
IRtwqAsyncResult result,
RTWQWORKITEM_KEY key 
)

Definition at line 1248 of file queue.c.

1249{
1250 struct queue *queue;
1251 HRESULT hr;
1252
1253 TRACE("%p, %ld, %p, %p.\n", event, priority, result, key);
1254
1256 return hr;
1257
1259
1260 return hr;
1261}
static HRESULT queue_submit_wait(struct queue *queue, HANDLE event, LONG priority, IRtwqAsyncResult *result, RTWQWORKITEM_KEY *key)
Definition: queue.c:822

◆ RtwqPutWorkItem()

HRESULT WINAPI RtwqPutWorkItem ( DWORD  queue,
LONG  priority,
IRtwqAsyncResult result 
)

Definition at line 1443 of file queue.c.

1444{
1445 TRACE("%#lx, %ld, %p.\n", queue, priority, result);
1446
1448}

◆ RtwqRegisterPlatformEvents()

HRESULT WINAPI RtwqRegisterPlatformEvents ( IRtwqPlatformEvents events)

Definition at line 1643 of file queue.c.

1644{
1645 FIXME("%p.\n", events);
1646
1647 return E_NOTIMPL;
1648}
HANDLE events[2]
Definition: event.c:4

◆ RtwqRegisterPlatformWithMMCSS()

HRESULT WINAPI RtwqRegisterPlatformWithMMCSS ( const WCHAR class,
DWORD taskid,
LONG  priority 
)

Definition at line 1600 of file queue.c.

1601{
1602 FIXME("%s, %p, %ld.\n", debugstr_w(class), taskid, priority);
1603
1604 return E_NOTIMPL;
1605}

◆ RtwqRemovePeriodicCallback()

HRESULT WINAPI RtwqRemovePeriodicCallback ( DWORD  key)

Definition at line 1410 of file queue.c.

1411{
1412 struct queue *queue;
1413 HRESULT hr;
1414
1415 TRACE("%#lx.\n", key);
1416
1418 return hr;
1419
1421}

◆ RtwqScheduleWorkItem()

HRESULT WINAPI RtwqScheduleWorkItem ( IRtwqAsyncResult result,
INT64  timeout,
RTWQWORKITEM_KEY key 
)

Definition at line 1276 of file queue.c.

1277{
1278 TRACE("%p, %s, %p.\n", result, wine_dbgstr_longlong(timeout), key);
1279
1281}
static HRESULT schedule_work_item(IRtwqAsyncResult *result, INT64 timeout, RTWQWORKITEM_KEY *key)
Definition: queue.c:1263

◆ RtwqSetDeadline()

HRESULT WINAPI RtwqSetDeadline ( DWORD  queue_id,
LONGLONG  deadline,
HANDLE request 
)

Definition at line 1532 of file queue.c.

1533{
1534 FIXME("%#lx, %s, %p.\n", queue_id, wine_dbgstr_longlong(deadline), request);
1535
1536 return E_NOTIMPL;
1537}

◆ RtwqSetDeadline2()

HRESULT WINAPI RtwqSetDeadline2 ( DWORD  queue_id,
LONGLONG  deadline,
LONGLONG  predeadline,
HANDLE request 
)

Definition at line 1539 of file queue.c.

1540{
1541 FIXME("%#lx, %s, %s, %p.\n", queue_id, wine_dbgstr_longlong(deadline), wine_dbgstr_longlong(predeadline), request);
1542
1543 return E_NOTIMPL;
1544}

◆ RtwqSetLongRunning()

HRESULT WINAPI RtwqSetLongRunning ( DWORD  queue_id,
BOOL  enable 
)

Definition at line 1476 of file queue.c.

1477{
1478 struct queue *queue;
1479 HRESULT hr;
1480 int i;
1481
1482 TRACE("%#lx, %d.\n", queue_id, enable);
1483
1484 lock_user_queue(queue_id);
1485
1486 if (SUCCEEDED(hr = grab_queue(queue_id, &queue)))
1487 {
1488 for (i = 0; i < ARRAY_SIZE(queue->envs); ++i)
1489 queue->envs[i].u.s.LongFunction = !!enable;
1490 }
1491
1492 unlock_user_queue(queue_id);
1493
1494 return hr;
1495}
GLboolean enable
Definition: glext.h:11120
union _TP_CALLBACK_ENVIRON_V3::@4726 u
struct _TP_CALLBACK_ENVIRON_V3::@4726::@4727 s

◆ RtwqShutdown()

HRESULT WINAPI RtwqShutdown ( void  )

Definition at line 1235 of file queue.c.

1236{
1237 if (platform_lock <= 0)
1238 return S_OK;
1239
1241 {
1243 }
1244
1245 return S_OK;
1246}
static void shutdown_system_queues(void)
Definition: queue.c:1217
#define InterlockedExchangeAdd
Definition: interlocked.h:196

Referenced by test_platform_init().

◆ RtwqStartup()

HRESULT WINAPI RtwqStartup ( void  )

Definition at line 1207 of file queue.c.

1208{
1210 {
1212 }
1213
1214 return S_OK;
1215}
static void init_system_queues(void)
Definition: queue.c:1181

Referenced by test_platform_init().

◆ RtwqUnjoinWorkQueue()

HRESULT WINAPI RtwqUnjoinWorkQueue ( DWORD  queue,
HANDLE  cookie 
)

Definition at line 1572 of file queue.c.

1573{
1574 FIXME("%#lx, %p.\n", queue, cookie);
1575
1576 return E_NOTIMPL;
1577}

◆ RtwqUnlockPlatform()

HRESULT WINAPI RtwqUnlockPlatform ( void  )

Definition at line 1174 of file queue.c.

1175{
1177
1178 return S_OK;
1179}

Referenced by async_result_Release().

◆ RtwqUnlockWorkQueue()

HRESULT WINAPI RtwqUnlockWorkQueue ( DWORD  queue)

Definition at line 1469 of file queue.c.

1470{
1471 TRACE("%#lx.\n", queue);
1472
1473 return unlock_user_queue(queue);
1474}

◆ RtwqUnregisterPlatformEvents()

HRESULT WINAPI RtwqUnregisterPlatformEvents ( IRtwqPlatformEvents events)

Definition at line 1650 of file queue.c.

1651{
1652 FIXME("%p.\n", events);
1653
1654 return E_NOTIMPL;
1655}

◆ RtwqUnregisterPlatformFromMMCSS()

HRESULT WINAPI RtwqUnregisterPlatformFromMMCSS ( void  )

Definition at line 1607 of file queue.c.

1608{
1609 FIXME("\n");
1610
1611 return E_NOTIMPL;
1612}

◆ schedule_work_item()

static HRESULT schedule_work_item ( IRtwqAsyncResult result,
INT64  timeout,
RTWQWORKITEM_KEY key 
)
static

Definition at line 1263 of file queue.c.

1264{
1265 struct queue *queue;
1266 HRESULT hr;
1267
1269 return hr;
1270
1271 TRACE("%p, %s, %p.\n", result, wine_dbgstr_longlong(timeout), key);
1272
1274}

Referenced by RtwqScheduleWorkItem().

◆ scheduled_item_callback()

static void CALLBACK scheduled_item_callback ( TP_CALLBACK_INSTANCE instance,
void context,
TP_TIMER timer 
)
static

Definition at line 777 of file queue.c.

778{
779 struct work_item *item = context;
780
781 TRACE("result object %p.\n", item->result);
782
784
785 IUnknown_Release(&item->IUnknown_iface);
786}

Referenced by queue_submit_timer().

◆ scheduled_item_cancelable_callback()

static void CALLBACK scheduled_item_cancelable_callback ( TP_CALLBACK_INSTANCE instance,
void context,
TP_TIMER timer 
)
static

Definition at line 788 of file queue.c.

789{
790 struct work_item *item = context;
791
792 TRACE("result object %p.\n", item->result);
793
796
797 IUnknown_Release(&item->IUnknown_iface);
798}

Referenced by queue_submit_timer().

◆ serial_queue_finalization_callback()

static void CALLBACK serial_queue_finalization_callback ( PTP_CALLBACK_INSTANCE  instance,
void user_data 
)
static

Definition at line 423 of file queue.c.

424{
425 struct work_item *item = (struct work_item *)user_data, *next_item;
426 struct queue *target_queue, *queue = item->queue;
427 HRESULT hr;
428
430
431 if ((next_item = serial_queue_get_next(queue, item)))
432 {
434 target_queue->ops->submit(target_queue, next_item);
435 else
436 WARN("Failed to grab queue for id %#lx, hr %#lx.\n", queue->target_queue, hr);
437 }
438
440
441 IUnknown_Release(&item->IUnknown_iface);
442}
static void * user_data
Definition: metahost.c:106
static struct work_item * serial_queue_get_next(struct queue *queue, struct work_item *item)
Definition: queue.c:412
DWORD target_queue
Definition: queue.c:189

Referenced by serial_queue_init().

◆ serial_queue_get_next()

static struct work_item * serial_queue_get_next ( struct queue queue,
struct work_item item 
)
static

Definition at line 412 of file queue.c.

413{
414 struct work_item *next_item = NULL;
415
416 list_remove(&item->entry);
417 if (!list_empty(&item->queue->pending_items))
418 next_item = LIST_ENTRY(list_head(&item->queue->pending_items), struct work_item, entry);
419
420 return next_item;
421}
static int list_empty(struct list_entry *head)
Definition: list.h:58
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by serial_queue_finalization_callback(), and serial_queue_submit().

◆ serial_queue_init()

static HRESULT serial_queue_init ( const struct queue_desc desc,
struct queue queue 
)
static

Definition at line 444 of file queue.c.

445{
447 queue->target_queue = desc->target_queue;
450
451 return S_OK;
452}
static const IRtwqAsyncCallbackVtbl queue_serial_callback_vtbl
Definition: queue.c:286
static void CALLBACK serial_queue_finalization_callback(PTP_CALLBACK_INSTANCE instance, void *user_data)
Definition: queue.c:423
IRtwqAsyncCallback IRtwqAsyncCallback_iface
Definition: queue.c:180
PTP_SIMPLE_CALLBACK finalization_callback
Definition: queue.c:188

◆ serial_queue_is_ack_token()

static struct work_item * serial_queue_is_ack_token ( struct queue queue,
struct work_item item 
)
static

Definition at line 461 of file queue.c.

462{
463 RTWQASYNCRESULT *async_result = (RTWQASYNCRESULT *)item->result;
464 struct work_item *head;
465
467 return NULL;
468
470 if (head->reply_result == item->result && async_result->pCallback == &queue->IRtwqAsyncCallback_iface)
471 return head;
472
473 return NULL;
474}
struct outqueuenode * head
Definition: adnsresfilter.c:66
if(dx< 0)
Definition: linetemp.h:194

Referenced by serial_queue_submit().

◆ serial_queue_shutdown()

static BOOL serial_queue_shutdown ( struct queue queue)
static

Definition at line 454 of file queue.c.

455{
457
458 return TRUE;
459}

◆ serial_queue_submit()

static void serial_queue_submit ( struct queue queue,
struct work_item item 
)
static

Definition at line 476 of file queue.c.

477{
478 struct work_item *head, *next_item = NULL;
479 struct queue *target_queue;
480 HRESULT hr;
481
482 /* In reply mode queue will advance when 'reply_result' is invoked, in regular mode it will advance automatically,
483 via finalization callback. */
484
485 if (item->flags & RTWQ_REPLY_CALLBACK)
486 {
488 WARN("Failed to create reply object, hr %#lx.\n", hr);
489 }
490 else
491 item->finalization_callback = queue->finalization_callback;
492
493 /* Serial queues could be chained together, detach from current queue before transitioning item to this one.
494 Items are not detached when submitted to pool queues, because pool queues won't forward them further. */
495 EnterCriticalSection(&item->queue->cs);
496 list_remove(&item->entry);
497 LeaveCriticalSection(&item->queue->cs);
498
500
501 item->queue = queue;
502
504 {
505 /* Ack receipt token - pop waiting item, advance. */
506 next_item = serial_queue_get_next(queue, head);
507 IUnknown_Release(&head->IUnknown_iface);
508 }
509 else
510 {
512 next_item = item;
514 IUnknown_AddRef(&item->IUnknown_iface);
515 }
516
517 if (next_item)
518 {
520 target_queue->ops->submit(target_queue, next_item);
521 else
522 WARN("Failed to grab queue for id %#lx, hr %#lx.\n", queue->target_queue, hr);
523 }
524
526}
static struct work_item * serial_queue_is_ack_token(struct queue *queue, struct work_item *item)
Definition: queue.c:461
HRESULT WINAPI RtwqCreateAsyncResult(IUnknown *object, IRtwqAsyncCallback *callback, IUnknown *state, IRtwqAsyncResult **out)
Definition: queue.c:1159

◆ shutdown_queue()

static void shutdown_queue ( struct queue queue)
static

Definition at line 671 of file queue.c.

672{
673 struct work_item *item, *item2;
674
675 if (!queue->ops || !queue->ops->shutdown(queue))
676 return;
677
680 {
681 list_remove(&item->entry);
682 IUnknown_Release(&item->IUnknown_iface);
683 }
685
687
688 memset(queue, 0, sizeof(*queue));
689}
static const struct metadata_item item2[]
Definition: metadata.c:3608
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by shutdown_system_queues(), and unlock_user_queue().

◆ shutdown_system_queues()

static void shutdown_system_queues ( void  )
static

Definition at line 1217 of file queue.c.

1218{
1219 unsigned int i;
1220 HRESULT hr;
1221
1223
1224 for (i = 0; i < ARRAY_SIZE(system_queues); ++i)
1225 {
1227 }
1228
1230 WARN("Failed to uninitialize MTA, hr %#lx.\n", hr);
1231
1233}
HRESULT WINAPI CoDecrementMTAUsage(CO_MTA_USAGE_COOKIE cookie)
Definition: combase.c:2917
static void shutdown_queue(struct queue *queue)
Definition: queue.c:671

Referenced by RtwqShutdown().

◆ standard_queue_cleanup_callback()

static void CALLBACK standard_queue_cleanup_callback ( void object_data,
void group_data 
)
static

Definition at line 315 of file queue.c.

316{
317}

Referenced by pool_queue_init().

◆ standard_queue_worker()

static void CALLBACK standard_queue_worker ( TP_CALLBACK_INSTANCE instance,
void context,
TP_WORK work 
)
static

Definition at line 364 of file queue.c.

365{
366 struct work_item *item = context;
367 RTWQASYNCRESULT *result = (RTWQASYNCRESULT *)item->result;
368
369 TRACE("result object %p.\n", result);
370
371 /* Submitting from serial queue in reply mode, use different result object acting as receipt token.
372 It's submitted to user callback still, but when invoked, special serial queue callback will be used
373 to ensure correct destination queue. */
374
375 IRtwqAsyncCallback_Invoke(result->pCallback, item->reply_result ? item->reply_result : item->result);
376
377 IUnknown_Release(&item->IUnknown_iface);
378}

Referenced by pool_queue_submit().

◆ unlock_user_queue()

static HRESULT unlock_user_queue ( DWORD  queue)
static

Definition at line 213 of file queue.c.

214{
215 HRESULT hr = RTWQ_E_INVALID_WORKQUEUE;
216 struct queue_handle *entry;
217
219 return S_OK;
220
223 if (entry && entry->refcount)
224 {
225 if (--entry->refcount == 0)
226 {
228 shutdown_queue((struct queue *)entry->obj);
229 free(entry->obj);
232 }
233 hr = S_OK;
234 }
236 return hr;
237}

Referenced by invoke_async_callback(), RtwqSetLongRunning(), RtwqUnlockWorkQueue(), and serial_queue_shutdown().

◆ waiting_item_callback()

static void CALLBACK waiting_item_callback ( TP_CALLBACK_INSTANCE instance,
void context,
TP_WAIT wait,
TP_WAIT_RESULT  wait_result 
)
static

Definition at line 752 of file queue.c.

754{
755 struct work_item *item = context;
756
757 TRACE("result object %p.\n", item->result);
758
760
761 IUnknown_Release(&item->IUnknown_iface);
762}

Referenced by queue_submit_wait().

◆ waiting_item_cancelable_callback()

static void CALLBACK waiting_item_cancelable_callback ( TP_CALLBACK_INSTANCE instance,
void context,
TP_WAIT wait,
TP_WAIT_RESULT  wait_result 
)
static

Definition at line 764 of file queue.c.

766{
767 struct work_item *item = context;
768
769 TRACE("result object %p.\n", item->result);
770
773
774 IUnknown_Release(&item->IUnknown_iface);
775}

Referenced by queue_submit_wait().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( mfplat  )

◆ work_item_AddRef()

static ULONG WINAPI work_item_AddRef ( IUnknown iface)
static

Definition at line 548 of file queue.c.

549{
551 return InterlockedIncrement(&item->refcount);
552}
static struct work_item * work_item_impl_from_IUnknown(IUnknown *iface)
Definition: queue.c:149

◆ work_item_impl_from_IUnknown()

static struct work_item * work_item_impl_from_IUnknown ( IUnknown iface)
static

Definition at line 149 of file queue.c.

150{
151 return CONTAINING_RECORD(iface, struct work_item, IUnknown_iface);
152}

Referenced by work_item_AddRef(), and work_item_Release().

◆ work_item_QueryInterface()

static HRESULT WINAPI work_item_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 535 of file queue.c.

536{
538 {
539 *obj = iface;
540 IUnknown_AddRef(iface);
541 return S_OK;
542 }
543
544 *obj = NULL;
545 return E_NOINTERFACE;
546}

◆ work_item_Release()

static ULONG WINAPI work_item_Release ( IUnknown iface)
static

Definition at line 554 of file queue.c.

555{
558
559 if (!refcount)
560 {
561 switch (item->type)
562 {
563 case WORK_ITEM_WORK:
564 if (item->u.work_object) CloseThreadpoolWork(item->u.work_object);
565 break;
566 case WORK_ITEM_WAIT:
567 if (item->u.wait_object) CloseThreadpoolWait(item->u.wait_object);
568 break;
569 case WORK_ITEM_TIMER:
570 if (item->u.timer_object) CloseThreadpoolTimer(item->u.timer_object);
571 break;
572 }
573 if (item->reply_result)
574 IRtwqAsyncResult_Release(item->reply_result);
575 IRtwqAsyncResult_Release(item->result);
576 free(item);
577 }
578
579 return refcount;
580}
LONG refcount
Definition: queue.c:131
WINBASEAPI VOID WINAPI CloseThreadpoolWork(_Inout_ PTP_WORK pwk)

Variable Documentation

◆ async_result_vtbl

const IRtwqAsyncResultVtbl async_result_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI async_result_Release(IRtwqAsyncResult *iface)
Definition: queue.c:1032
static HRESULT WINAPI async_result_GetObject(IRtwqAsyncResult *iface, IUnknown **object)
Definition: queue.c:1092
static IUnknown *WINAPI async_result_GetStateNoAddRef(IRtwqAsyncResult *iface)
Definition: queue.c:1107
static HRESULT WINAPI async_result_GetState(IRtwqAsyncResult *iface, IUnknown **state)
Definition: queue.c:1057
static ULONG WINAPI async_result_AddRef(IRtwqAsyncResult *iface)
Definition: queue.c:1022
static HRESULT WINAPI async_result_QueryInterface(IRtwqAsyncResult *iface, REFIID riid, void **obj)
Definition: queue.c:1005
static HRESULT WINAPI async_result_SetStatus(IRtwqAsyncResult *iface, HRESULT status)
Definition: queue.c:1081
static HRESULT WINAPI async_result_GetStatus(IRtwqAsyncResult *iface)
Definition: queue.c:1072

Definition at line 1116 of file queue.c.

Referenced by create_async_result().

◆ mta_cookie

CO_MTA_USAGE_COOKIE mta_cookie
static

Definition at line 70 of file queue.c.

◆ next_free_user_queue

struct queue_handle* next_free_user_queue
static

Definition at line 55 of file queue.c.

Referenced by alloc_user_queue(), and unlock_user_queue().

◆ next_item_key

LONG next_item_key
static

Definition at line 35 of file queue.c.

Referenced by generate_item_key().

◆ next_unused_user_queue

struct queue_handle* next_unused_user_queue = user_queues
static

Definition at line 56 of file queue.c.

Referenced by alloc_user_queue().

◆ periodic_callback_vtbl

const IRtwqAsyncCallbackVtbl periodic_callback_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI periodic_callback_Release(IRtwqAsyncCallback *iface)
Definition: queue.c:1319
static HRESULT WINAPI periodic_callback_QueryInterface(IRtwqAsyncCallback *iface, REFIID riid, void **obj)
Definition: queue.c:1295
static ULONG WINAPI periodic_callback_AddRef(IRtwqAsyncCallback *iface)
Definition: queue.c:1309
static HRESULT WINAPI periodic_callback_Invoke(IRtwqAsyncCallback *iface, IRtwqAsyncResult *result)
Definition: queue.c:1337
static HRESULT WINAPI periodic_callback_GetParameters(IRtwqAsyncCallback *iface, DWORD *flags, DWORD *queue)
Definition: queue.c:1332

Definition at line 1353 of file queue.c.

Referenced by create_periodic_callback_obj().

◆ platform_lock

LONG platform_lock
static

◆ pool_queue_ops

const struct queue_ops pool_queue_ops
static
Initial value:
=
{
}
static void pool_queue_submit(struct queue *queue, struct work_item *item)
Definition: queue.c:380
static BOOL pool_queue_shutdown(struct queue *queue)
Definition: queue.c:352
static HRESULT pool_queue_init(const struct queue_desc *desc, struct queue *queue)
Definition: queue.c:319

Definition at line 405 of file queue.c.

Referenced by grab_queue(), init_system_queues(), RtwqAllocateWorkQueue(), and RtwqLockSharedWorkQueue().

◆ priorities

◆ queue_generation

WORD queue_generation
static

Definition at line 57 of file queue.c.

Referenced by alloc_user_queue().

◆ queue_serial_callback_vtbl

const IRtwqAsyncCallbackVtbl queue_serial_callback_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI queue_serial_callback_Release(IRtwqAsyncCallback *iface)
Definition: queue.c:263
static HRESULT WINAPI queue_serial_callback_QueryInterface(IRtwqAsyncCallback *iface, REFIID riid, void **obj)
Definition: queue.c:244
static ULONG WINAPI queue_serial_callback_AddRef(IRtwqAsyncCallback *iface)
Definition: queue.c:258
static HRESULT WINAPI queue_serial_callback_Invoke(IRtwqAsyncCallback *iface, IRtwqAsyncResult *result)
Definition: queue.c:278
static HRESULT WINAPI queue_serial_callback_GetParameters(IRtwqAsyncCallback *iface, DWORD *flags, DWORD *queue_id)
Definition: queue.c:268

Definition at line 286 of file queue.c.

Referenced by serial_queue_init().

◆ queues_critsect_debug

CRITICAL_SECTION_DEBUG queues_critsect_debug
static
Initial value:
=
{
0, 0, { (DWORD_PTR)(__FILE__ ": queues_section") }
}
static CRITICAL_SECTION_DEBUG queues_critsect_debug
Definition: queue.c:61
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 61 of file queue.c.

◆ queues_section

◆ serial_queue_ops

const struct queue_ops serial_queue_ops
static
Initial value:
=
{
}
static BOOL serial_queue_shutdown(struct queue *queue)
Definition: queue.c:454
static void serial_queue_submit(struct queue *queue, struct work_item *item)
Definition: queue.c:476
static HRESULT serial_queue_init(const struct queue_desc *desc, struct queue *queue)
Definition: queue.c:444

Definition at line 528 of file queue.c.

Referenced by RtwqAllocateSerialWorkQueue().

◆ shared_mt_queue

DWORD shared_mt_queue
static

Definition at line 58 of file queue.c.

Referenced by RtwqLockSharedWorkQueue(), and unlock_user_queue().

◆ system_queues

struct queue system_queues[SYS_QUEUE_COUNT]
static

Definition at line 295 of file queue.c.

Referenced by get_system_queue(), grab_queue(), init_system_queues(), and shutdown_system_queues().

◆ user_queues

Definition at line 54 of file queue.c.

Referenced by alloc_user_queue(), and get_queue_obj().

◆ work_item_vtbl

const IUnknownVtbl work_item_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI work_item_Release(IUnknown *iface)
Definition: queue.c:554
static ULONG WINAPI work_item_AddRef(IUnknown *iface)
Definition: queue.c:548
static HRESULT WINAPI work_item_QueryInterface(IUnknown *iface, REFIID riid, void **obj)
Definition: queue.c:535

Definition at line 582 of file queue.c.

Referenced by alloc_work_item().