mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
[CHEW]
- Fix formatting, comments. - Delete an empty directory. svn path=/trunk/; revision=43386
This commit is contained in:
parent
ac4cdf694c
commit
27f05c27a8
4 changed files with 88 additions and 76 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: include/chew/chew.h
|
||||
* FILE: include/reactos/chew/chew.h
|
||||
* PURPOSE: Common Highlevel Executive Worker
|
||||
*
|
||||
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||
|
@ -14,15 +14,16 @@
|
|||
* Initialize CHEW, given a device object (since IoAllocateWorkItem relies on
|
||||
* it).
|
||||
*/
|
||||
VOID ChewInit( PDEVICE_OBJECT DeviceObject );
|
||||
VOID ChewInit(PDEVICE_OBJECT DeviceObject);
|
||||
|
||||
/**
|
||||
* Shutdown CHEW, waits for remaining work items.
|
||||
*/
|
||||
VOID ChewShutdown();
|
||||
VOID ChewShutdown(VOID);
|
||||
|
||||
/**
|
||||
* Creates and queues a work item.
|
||||
*/
|
||||
BOOLEAN ChewCreate
|
||||
( VOID (*Worker)(PVOID), PVOID WorkerContext );
|
||||
BOOLEAN ChewCreate(VOID (*Worker)(PVOID), PVOID WorkerContext);
|
||||
|
||||
#endif/*_REACTOS_CHEW_H*/
|
||||
|
|
0
reactos/include/reactos/chew/chew/.gitignore
vendored
0
reactos/include/reactos/chew/chew/.gitignore
vendored
|
@ -4,4 +4,4 @@
|
|||
<define name="_NTOSKRNL_" />
|
||||
<include base="chew">include</include>
|
||||
<file>workqueue.c</file>
|
||||
</module>
|
||||
</module>
|
||||
|
|
|
@ -1,82 +1,93 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: drivers/lib/chew/workqueue.c
|
||||
* PURPOSE: Common Highlevel Executive Worker
|
||||
*
|
||||
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||
*/
|
||||
#include <ntddk.h>
|
||||
#include <chew/chew.h>
|
||||
|
||||
#define NDEBUG
|
||||
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: lib/drivers/chew/workqueue.c
|
||||
* PURPOSE: Common Highlevel Executive Worker
|
||||
*
|
||||
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||
*/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <chew/chew.h>
|
||||
|
||||
#define NDEBUG
|
||||
//#include <debug.h>
|
||||
|
||||
#define FOURCC(w,x,y,z) (((w) << 24) | ((x) << 16) | ((y) << 8) | (z))
|
||||
#define CHEW_TAG FOURCC('C','H','E','W')
|
||||
|
||||
PDEVICE_OBJECT WorkQueueDevice;
|
||||
LIST_ENTRY WorkQueue;
|
||||
#define CHEW_TAG FOURCC('C','H','E','W')
|
||||
|
||||
PDEVICE_OBJECT WorkQueueDevice;
|
||||
LIST_ENTRY WorkQueue;
|
||||
KSPIN_LOCK WorkQueueLock;
|
||||
KEVENT WorkQueueClear;
|
||||
|
||||
typedef struct _WORK_ITEM {
|
||||
LIST_ENTRY Entry;
|
||||
PIO_WORKITEM WorkItem;
|
||||
VOID (*Worker)( PVOID WorkerContext );
|
||||
PVOID WorkerContext;
|
||||
} WORK_ITEM, *PWORK_ITEM;
|
||||
|
||||
VOID ChewInit( PDEVICE_OBJECT DeviceObject ) {
|
||||
WorkQueueDevice = DeviceObject;
|
||||
InitializeListHead( &WorkQueue );
|
||||
KeInitializeSpinLock( &WorkQueueLock );
|
||||
KeInitializeEvent(&WorkQueueClear, NotificationEvent, TRUE);
|
||||
}
|
||||
|
||||
VOID ChewShutdown() {
|
||||
KeWaitForSingleObject(&WorkQueueClear, Executive, KernelMode, FALSE, NULL);
|
||||
}
|
||||
|
||||
VOID NTAPI ChewWorkItem( PDEVICE_OBJECT DeviceObject, PVOID ChewItem ) {
|
||||
KEVENT WorkQueueClear;
|
||||
|
||||
typedef struct _WORK_ITEM
|
||||
{
|
||||
LIST_ENTRY Entry;
|
||||
PIO_WORKITEM WorkItem;
|
||||
VOID (*Worker)(PVOID WorkerContext);
|
||||
PVOID WorkerContext;
|
||||
} WORK_ITEM, *PWORK_ITEM;
|
||||
|
||||
VOID ChewInit(PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
WorkQueueDevice = DeviceObject;
|
||||
InitializeListHead(&WorkQueue);
|
||||
KeInitializeSpinLock(&WorkQueueLock);
|
||||
KeInitializeEvent(&WorkQueueClear, NotificationEvent, TRUE);
|
||||
}
|
||||
|
||||
VOID ChewShutdown(VOID)
|
||||
{
|
||||
KeWaitForSingleObject(&WorkQueueClear, Executive, KernelMode, FALSE, NULL);
|
||||
}
|
||||
|
||||
VOID NTAPI ChewWorkItem(PDEVICE_OBJECT DeviceObject, PVOID ChewItem)
|
||||
{
|
||||
PWORK_ITEM WorkItem = ChewItem;
|
||||
KIRQL OldIrql;
|
||||
|
||||
WorkItem->Worker( WorkItem->WorkerContext );
|
||||
|
||||
IoFreeWorkItem( WorkItem->WorkItem );
|
||||
KIRQL OldIrql;
|
||||
|
||||
WorkItem->Worker(WorkItem->WorkerContext);
|
||||
|
||||
IoFreeWorkItem(WorkItem->WorkItem);
|
||||
|
||||
KeAcquireSpinLock(&WorkQueueLock, &OldIrql);
|
||||
RemoveEntryList(&WorkItem->Entry);
|
||||
|
||||
if (IsListEmpty(&WorkQueue))
|
||||
KeSetEvent(&WorkQueueClear, 0, FALSE);
|
||||
|
||||
KeReleaseSpinLock(&WorkQueueLock, OldIrql);
|
||||
|
||||
ExFreePoolWithTag(WorkItem, CHEW_TAG);
|
||||
}
|
||||
|
||||
BOOLEAN ChewCreate
|
||||
( VOID (*Worker)( PVOID ), PVOID WorkerContext ) {
|
||||
ExFreePoolWithTag(WorkItem, CHEW_TAG);
|
||||
}
|
||||
|
||||
BOOLEAN ChewCreate(VOID (*Worker)(PVOID), PVOID WorkerContext)
|
||||
{
|
||||
PWORK_ITEM Item;
|
||||
Item = ExAllocatePoolWithTag
|
||||
( NonPagedPool,
|
||||
sizeof( WORK_ITEM ),
|
||||
CHEW_TAG );
|
||||
|
||||
if( Item ) {
|
||||
Item->WorkItem = IoAllocateWorkItem( WorkQueueDevice );
|
||||
if( !Item->WorkItem ) {
|
||||
ExFreePool( Item );
|
||||
return FALSE;
|
||||
}
|
||||
Item->Worker = Worker;
|
||||
Item->WorkerContext = WorkerContext;
|
||||
ExInterlockedInsertTailList( &WorkQueue, &Item->Entry, &WorkQueueLock );
|
||||
KeResetEvent(&WorkQueueClear);
|
||||
IoQueueWorkItem( Item->WorkItem, ChewWorkItem, DelayedWorkQueue, Item );
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
Item = ExAllocatePoolWithTag(NonPagedPool,
|
||||
sizeof(WORK_ITEM),
|
||||
CHEW_TAG);
|
||||
|
||||
if (Item)
|
||||
{
|
||||
Item->WorkItem = IoAllocateWorkItem(WorkQueueDevice);
|
||||
if (!Item->WorkItem)
|
||||
{
|
||||
ExFreePool(Item);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Item->Worker = Worker;
|
||||
Item->WorkerContext = WorkerContext;
|
||||
ExInterlockedInsertTailList(&WorkQueue, &Item->Entry, &WorkQueueLock);
|
||||
KeResetEvent(&WorkQueueClear);
|
||||
IoQueueWorkItem(Item->WorkItem, ChewWorkItem, DelayedWorkQueue, Item);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue