ReactOS 0.4.16-dev-306-g647d351
workqueue.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: lib/drivers/chew/workqueue.c
5 * PURPOSE: Common Highlevel Executive Worker
6 *
7 * PROGRAMMERS: arty (ayerkes@speakeasy.net)
8 */
9
10#include <wdm.h>
11
12#define FOURCC(w,x,y,z) (((w) << 24) | ((x) << 16) | ((y) << 8) | (z))
13#define CHEW_TAG FOURCC('C','H','E','W')
14
19
20typedef struct _WORK_ITEM
21{
27
29{
34}
35
37{
39}
40
42{
43 PWORK_ITEM WorkItem = ChewItem;
45
46 WorkItem->Worker(WorkItem->WorkerContext);
47
48 IoFreeWorkItem(WorkItem->WorkItem);
49
52
55
57
59}
60
61BOOLEAN ChewCreate(VOID (*Worker)(PVOID), PVOID WorkerContext)
62{
65 sizeof(WORK_ITEM),
66 CHEW_TAG);
67
68 if (Item)
69 {
71 if (!Item->WorkItem)
72 {
74 return FALSE;
75 }
76
77 Item->Worker = Worker;
78 Item->WorkerContext = WorkerContext;
82
83 return TRUE;
84 }
85 else
86 {
87 return FALSE;
88 }
89}
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
Definition: typedefs.h:120
PVOID WorkerContext
Definition: workqueue.c:25
LIST_ENTRY Entry
Definition: workqueue.c:22
PIO_WORKITEM WorkItem
Definition: workqueue.c:23
VOID(* Worker)(PVOID WorkerContext)
Definition: workqueue.c:24
#define NTAPI
Definition: typedefs.h:36
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115
LIST_ENTRY WorkQueue
Definition: workqueue.c:16
struct _WORK_ITEM * PWORK_ITEM
#define CHEW_TAG
Definition: workqueue.c:13
struct _WORK_ITEM WORK_ITEM
BOOLEAN ChewCreate(VOID(*Worker)(PVOID), PVOID WorkerContext)
Definition: workqueue.c:61
VOID ChewShutdown(VOID)
Definition: workqueue.c:36
PDEVICE_OBJECT WorkQueueDevice
Definition: workqueue.c:15
VOID NTAPI ChewWorkItem(PDEVICE_OBJECT DeviceObject, PVOID ChewItem)
Definition: workqueue.c:41
KSPIN_LOCK WorkQueueLock
Definition: workqueue.c:17
KEVENT WorkQueueClear
Definition: workqueue.c:18
VOID ChewInit(PDEVICE_OBJECT DeviceObject)
Definition: workqueue.c:28
@ DelayedWorkQueue
Definition: extypes.h:190
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ Executive
Definition: ketypes.h:415