mirror of
https://github.com/reactos/reactos.git
synced 2025-06-30 22:41:22 +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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: include/chew/chew.h
|
* FILE: include/reactos/chew/chew.h
|
||||||
* PURPOSE: Common Highlevel Executive Worker
|
* PURPOSE: Common Highlevel Executive Worker
|
||||||
*
|
*
|
||||||
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||||
|
@ -15,14 +15,15 @@
|
||||||
* it).
|
* it).
|
||||||
*/
|
*/
|
||||||
VOID ChewInit(PDEVICE_OBJECT DeviceObject);
|
VOID ChewInit(PDEVICE_OBJECT DeviceObject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown CHEW, waits for remaining work items.
|
* Shutdown CHEW, waits for remaining work items.
|
||||||
*/
|
*/
|
||||||
VOID ChewShutdown();
|
VOID ChewShutdown(VOID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and queues a work item.
|
* Creates and queues a work item.
|
||||||
*/
|
*/
|
||||||
BOOLEAN ChewCreate
|
BOOLEAN ChewCreate(VOID (*Worker)(PVOID), PVOID WorkerContext);
|
||||||
( VOID (*Worker)(PVOID), PVOID WorkerContext );
|
|
||||||
|
|
||||||
#endif/*_REACTOS_CHEW_H*/
|
#endif/*_REACTOS_CHEW_H*/
|
||||||
|
|
0
reactos/include/reactos/chew/chew/.gitignore
vendored
0
reactos/include/reactos/chew/chew/.gitignore
vendored
|
@ -1,15 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: drivers/lib/chew/workqueue.c
|
* FILE: lib/drivers/chew/workqueue.c
|
||||||
* PURPOSE: Common Highlevel Executive Worker
|
* PURPOSE: Common Highlevel Executive Worker
|
||||||
*
|
*
|
||||||
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ntddk.h>
|
#include <ntddk.h>
|
||||||
#include <chew/chew.h>
|
#include <chew/chew.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
//#include <debug.h>
|
||||||
|
|
||||||
#define FOURCC(w,x,y,z) (((w) << 24) | ((x) << 16) | ((y) << 8) | (z))
|
#define FOURCC(w,x,y,z) (((w) << 24) | ((x) << 16) | ((y) << 8) | (z))
|
||||||
#define CHEW_TAG FOURCC('C','H','E','W')
|
#define CHEW_TAG FOURCC('C','H','E','W')
|
||||||
|
@ -19,25 +21,29 @@ LIST_ENTRY WorkQueue;
|
||||||
KSPIN_LOCK WorkQueueLock;
|
KSPIN_LOCK WorkQueueLock;
|
||||||
KEVENT WorkQueueClear;
|
KEVENT WorkQueueClear;
|
||||||
|
|
||||||
typedef struct _WORK_ITEM {
|
typedef struct _WORK_ITEM
|
||||||
|
{
|
||||||
LIST_ENTRY Entry;
|
LIST_ENTRY Entry;
|
||||||
PIO_WORKITEM WorkItem;
|
PIO_WORKITEM WorkItem;
|
||||||
VOID (*Worker)(PVOID WorkerContext);
|
VOID (*Worker)(PVOID WorkerContext);
|
||||||
PVOID WorkerContext;
|
PVOID WorkerContext;
|
||||||
} WORK_ITEM, *PWORK_ITEM;
|
} WORK_ITEM, *PWORK_ITEM;
|
||||||
|
|
||||||
VOID ChewInit( PDEVICE_OBJECT DeviceObject ) {
|
VOID ChewInit(PDEVICE_OBJECT DeviceObject)
|
||||||
|
{
|
||||||
WorkQueueDevice = DeviceObject;
|
WorkQueueDevice = DeviceObject;
|
||||||
InitializeListHead(&WorkQueue);
|
InitializeListHead(&WorkQueue);
|
||||||
KeInitializeSpinLock(&WorkQueueLock);
|
KeInitializeSpinLock(&WorkQueueLock);
|
||||||
KeInitializeEvent(&WorkQueueClear, NotificationEvent, TRUE);
|
KeInitializeEvent(&WorkQueueClear, NotificationEvent, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ChewShutdown() {
|
VOID ChewShutdown(VOID)
|
||||||
|
{
|
||||||
KeWaitForSingleObject(&WorkQueueClear, Executive, KernelMode, FALSE, NULL);
|
KeWaitForSingleObject(&WorkQueueClear, Executive, KernelMode, FALSE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID NTAPI ChewWorkItem( PDEVICE_OBJECT DeviceObject, PVOID ChewItem ) {
|
VOID NTAPI ChewWorkItem(PDEVICE_OBJECT DeviceObject, PVOID ChewItem)
|
||||||
|
{
|
||||||
PWORK_ITEM WorkItem = ChewItem;
|
PWORK_ITEM WorkItem = ChewItem;
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
|
|
||||||
|
@ -50,25 +56,28 @@ VOID NTAPI ChewWorkItem( PDEVICE_OBJECT DeviceObject, PVOID ChewItem ) {
|
||||||
|
|
||||||
if (IsListEmpty(&WorkQueue))
|
if (IsListEmpty(&WorkQueue))
|
||||||
KeSetEvent(&WorkQueueClear, 0, FALSE);
|
KeSetEvent(&WorkQueueClear, 0, FALSE);
|
||||||
|
|
||||||
KeReleaseSpinLock(&WorkQueueLock, OldIrql);
|
KeReleaseSpinLock(&WorkQueueLock, OldIrql);
|
||||||
|
|
||||||
ExFreePoolWithTag(WorkItem, CHEW_TAG);
|
ExFreePoolWithTag(WorkItem, CHEW_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN ChewCreate
|
BOOLEAN ChewCreate(VOID (*Worker)(PVOID), PVOID WorkerContext)
|
||||||
( VOID (*Worker)( PVOID ), PVOID WorkerContext ) {
|
{
|
||||||
PWORK_ITEM Item;
|
PWORK_ITEM Item;
|
||||||
Item = ExAllocatePoolWithTag
|
Item = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
( NonPagedPool,
|
|
||||||
sizeof(WORK_ITEM),
|
sizeof(WORK_ITEM),
|
||||||
CHEW_TAG);
|
CHEW_TAG);
|
||||||
|
|
||||||
if( Item ) {
|
if (Item)
|
||||||
|
{
|
||||||
Item->WorkItem = IoAllocateWorkItem(WorkQueueDevice);
|
Item->WorkItem = IoAllocateWorkItem(WorkQueueDevice);
|
||||||
if( !Item->WorkItem ) {
|
if (!Item->WorkItem)
|
||||||
|
{
|
||||||
ExFreePool(Item);
|
ExFreePool(Item);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item->Worker = Worker;
|
Item->Worker = Worker;
|
||||||
Item->WorkerContext = WorkerContext;
|
Item->WorkerContext = WorkerContext;
|
||||||
ExInterlockedInsertTailList(&WorkQueue, &Item->Entry, &WorkQueueLock);
|
ExInterlockedInsertTailList(&WorkQueue, &Item->Entry, &WorkQueueLock);
|
||||||
|
@ -76,7 +85,9 @@ BOOLEAN ChewCreate
|
||||||
IoQueueWorkItem(Item->WorkItem, ChewWorkItem, DelayedWorkQueue, Item);
|
IoQueueWorkItem(Item->WorkItem, ChewWorkItem, DelayedWorkQueue, Item);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue