ReactOS 0.4.16-dev-109-gf4cb10f
workqueue.c File Reference
#include <wdm.h>
Include dependency graph for workqueue.c:

Go to the source code of this file.

Classes

struct  _WORK_ITEM
 

Macros

#define FOURCC(w, x, y, z)   (((w) << 24) | ((x) << 16) | ((y) << 8) | (z))
 
#define CHEW_TAG   FOURCC('C','H','E','W')
 

Typedefs

typedef struct _WORK_ITEM WORK_ITEM
 
typedef struct _WORK_ITEMPWORK_ITEM
 

Functions

VOID ChewInit (PDEVICE_OBJECT DeviceObject)
 
VOID ChewShutdown (VOID)
 
VOID NTAPI ChewWorkItem (PDEVICE_OBJECT DeviceObject, PVOID ChewItem)
 
BOOLEAN ChewCreate (VOID(*Worker)(PVOID), PVOID WorkerContext)
 

Variables

PDEVICE_OBJECT WorkQueueDevice
 
LIST_ENTRY WorkQueue
 
KSPIN_LOCK WorkQueueLock
 
KEVENT WorkQueueClear
 

Macro Definition Documentation

◆ CHEW_TAG

#define CHEW_TAG   FOURCC('C','H','E','W')

Definition at line 13 of file workqueue.c.

◆ FOURCC

#define FOURCC (   w,
  x,
  y,
  z 
)    (((w) << 24) | ((x) << 16) | ((y) << 8) | (z))

Definition at line 12 of file workqueue.c.

Typedef Documentation

◆ PWORK_ITEM

◆ WORK_ITEM

Function Documentation

◆ ChewCreate()

BOOLEAN ChewCreate ( VOID(*)(PVOID Worker,
PVOID  WorkerContext 
)

Creates and queues a work item.

Definition at line 61 of file workqueue.c.

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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
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
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
LIST_ENTRY WorkQueue
Definition: workqueue.c:16
#define CHEW_TAG
Definition: workqueue.c:13
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
@ DelayedWorkQueue
Definition: extypes.h:190

Referenced by CompleteBucket(), LanSubmitReceiveWork(), LoopTransmit(), and ProtocolStatus().

◆ ChewInit()

VOID ChewInit ( PDEVICE_OBJECT  DeviceObject)

Initialize CHEW, given a device object (since IoAllocateWorkItem relies on it).

Definition at line 28 of file workqueue.c.

29{
34}
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
@ NotificationEvent
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by DriverEntry().

◆ ChewShutdown()

VOID ChewShutdown ( VOID  )

Shutdown CHEW, waits for remaining work items.

Definition at line 36 of file workqueue.c.

37{
39}
#define NULL
Definition: types.h:112
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KernelMode
Definition: asm.h:34
@ Executive
Definition: ketypes.h:415

Referenced by TiUnload().

◆ ChewWorkItem()

VOID NTAPI ChewWorkItem ( PDEVICE_OBJECT  DeviceObject,
PVOID  ChewItem 
)

Definition at line 41 of file workqueue.c.

42{
43 PWORK_ITEM WorkItem = ChewItem;
45
46 WorkItem->Worker(WorkItem->WorkerContext);
47
48 IoFreeWorkItem(WorkItem->WorkItem);
49
52
55
57
59}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
UCHAR KIRQL
Definition: env_spec_w32.h:591
#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
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by ChewCreate().

Variable Documentation

◆ WorkQueue

◆ WorkQueueClear

KEVENT WorkQueueClear

Definition at line 18 of file workqueue.c.

Referenced by ChewCreate(), ChewInit(), ChewShutdown(), and ChewWorkItem().

◆ WorkQueueDevice

PDEVICE_OBJECT WorkQueueDevice

Definition at line 15 of file workqueue.c.

Referenced by ChewCreate(), and ChewInit().

◆ WorkQueueLock

KSPIN_LOCK WorkQueueLock

Definition at line 17 of file workqueue.c.

Referenced by ChewCreate(), ChewInit(), and ChewWorkItem().