mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:03:02 +00:00
Working work item library.
- Slightly changed semantics of ChewCreate: the work may be performed inline if we're in the right irql already. - The user data is copied automatically if the call succeeds and a work item is created. - The address of the work item is returned through an argument if it was allocated. svn path=/trunk/; revision=20127
This commit is contained in:
parent
0e5dec753d
commit
9b271017a5
2 changed files with 47 additions and 12 deletions
|
@ -1,16 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS TCP/IP protocol driver
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: tcpip/main.c
|
* FILE: drivers/lib/chew/workqueue.c
|
||||||
* PURPOSE: Common Highlevel Executive Worker
|
* PURPOSE: Common Highlevel Executive Worker
|
||||||
* PROGRAMMERS: Art Yerkes
|
*
|
||||||
* REVISIONS:
|
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||||
* CSH 10/12-2005 Created
|
|
||||||
*/
|
*/
|
||||||
#include <ntddk.h>
|
#include <ntddk.h>
|
||||||
#include <chew/chew.h>
|
#include <chew/chew.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
|
|
||||||
#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))
|
||||||
|
|
||||||
|
@ -51,6 +50,8 @@ VOID ChewShutdown() {
|
||||||
VOID STDCALL ChewWorkItem( PDEVICE_OBJECT DeviceObject, PVOID ChewItem ) {
|
VOID STDCALL ChewWorkItem( PDEVICE_OBJECT DeviceObject, PVOID ChewItem ) {
|
||||||
PWORK_ITEM WorkItem = ChewItem;
|
PWORK_ITEM WorkItem = ChewItem;
|
||||||
|
|
||||||
|
RemoveEntryList( &WorkItem->Entry );
|
||||||
|
|
||||||
if( WorkItem->Worker )
|
if( WorkItem->Worker )
|
||||||
WorkItem->Worker( WorkItem->UserSpace );
|
WorkItem->Worker( WorkItem->UserSpace );
|
||||||
|
|
||||||
|
@ -61,7 +62,9 @@ VOID STDCALL ChewWorkItem( PDEVICE_OBJECT DeviceObject, PVOID ChewItem ) {
|
||||||
BOOLEAN ChewCreate
|
BOOLEAN ChewCreate
|
||||||
( PVOID *ItemPtr, UINT Bytes, VOID (*Worker)( PVOID ), PVOID UserSpace ) {
|
( PVOID *ItemPtr, UINT Bytes, VOID (*Worker)( PVOID ), PVOID UserSpace ) {
|
||||||
PWORK_ITEM Item;
|
PWORK_ITEM Item;
|
||||||
|
|
||||||
if( KeGetCurrentIrql() == PASSIVE_LEVEL ) {
|
if( KeGetCurrentIrql() == PASSIVE_LEVEL ) {
|
||||||
|
if( ItemPtr )
|
||||||
*ItemPtr = NULL;
|
*ItemPtr = NULL;
|
||||||
Worker(UserSpace);
|
Worker(UserSpace);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -86,13 +89,15 @@ BOOLEAN ChewCreate
|
||||||
IoQueueWorkItem
|
IoQueueWorkItem
|
||||||
( Item->WorkItem, ChewWorkItem, CriticalWorkQueue, Item );
|
( Item->WorkItem, ChewWorkItem, CriticalWorkQueue, Item );
|
||||||
|
|
||||||
|
if( ItemPtr )
|
||||||
*ItemPtr = Item;
|
*ItemPtr = Item;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VOID ChewRemove( PVOID Item ) {
|
VOID ChewRemove( PVOID Item ) {
|
||||||
PWORK_ITEM WorkItem = Item;
|
PWORK_ITEM WorkItem = Item;
|
||||||
|
|
|
@ -1,10 +1,40 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: include/chew/chew.h
|
||||||
|
* PURPOSE: Common Highlevel Executive Worker
|
||||||
|
*
|
||||||
|
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _REACTOS_CHEW_H
|
#ifndef _REACTOS_CHEW_H
|
||||||
#define _REACTOS_CHEW_H
|
#define _REACTOS_CHEW_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize CHEW, given a device object (since IoAllocateWorkItem relies on
|
||||||
|
* it).
|
||||||
|
*/
|
||||||
VOID ChewInit( PDEVICE_OBJECT DeviceObject );
|
VOID ChewInit( PDEVICE_OBJECT DeviceObject );
|
||||||
|
/**
|
||||||
|
* Shutdown CHEW, including removing remaining work items.
|
||||||
|
*/
|
||||||
VOID ChewShutdown();
|
VOID ChewShutdown();
|
||||||
|
/**
|
||||||
|
* Create a work item, or perform the work, based on IRQL.
|
||||||
|
* At passive level, Worker is called directly on UserSpace.
|
||||||
|
* At greater than passive level, a work item is created with Bytes
|
||||||
|
* context area and data copied from UserSpace.
|
||||||
|
* If a work item is created, Item contains the address and the function
|
||||||
|
* returns true.
|
||||||
|
* If the work is performed immediately, Item contains NULL and the
|
||||||
|
* function returns true.
|
||||||
|
* Else, the function returns false and Item is undefined.
|
||||||
|
*/
|
||||||
BOOLEAN ChewCreate
|
BOOLEAN ChewCreate
|
||||||
( PVOID *Item, UINT Bytes, VOID (*Worker)(PVOID), PVOID UserSpace );
|
( PVOID *Item, UINT Bytes, VOID (*Worker)(PVOID), PVOID UserSpace );
|
||||||
|
/**
|
||||||
|
* Remove a work item, given the pointer returned to Item in ChewCreate.
|
||||||
|
*/
|
||||||
VOID ChewRemove( PVOID Item );
|
VOID ChewRemove( PVOID Item );
|
||||||
|
|
||||||
#endif/*_REACTOS_CHEW_H*/
|
#endif/*_REACTOS_CHEW_H*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue