BazisLib::DDK::IrpQueue Class Reference

#include <irpqueue.h>

Collaboration diagram for BazisLib::DDK::IrpQueue:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 IrpQueue ()
 ~IrpQueue ()
bool EnqueuePacket (PIRP pIrp, void *pContext)
PIRP DequeuePacket (void **ppContext)
void Shutdown ()
bool IsShutDown ()
int GetPacketCount ()
void * operator new (unsigned size)

Private Attributes

PIRP m_pFirstIrp
PIRP m_pLastIrp
bool m_bShutdown
bool m_bLastPacketDequeued
KSemaphore m_Semaphore
KSpinLock m_QueueSpinLock
int m_PacketCount


Detailed Description

This class represents a thread-safe IRP queue. It is internally used by the Device class. Use the Device::EnqueuePacket() method to add an IRP to device queue. This class is used instead of native IoStartPacket()/StartIo() mechanism because the latter does not ensure that the IRP started with IoStartPacket() will be processed from the dispatcher thread, that can be vital in some cases (for example, in virtual disk drivers when FSD call in the same thread that dispatches a call from FSD may cause infrequent crashes caused by TLS-like IoSetTopLevelIrp().

Remarks:
This class uses IRP::Tail::Overlay::DriverContext for storing pointers in the following way: [0] - Next queued IRP pointer [1] - IRP context. Usually contains the IncomingIrp flags.

DO NOT create any instances of this class in paged memory. Always use new() operator.

See comments in the beginning of IRP.H for use example.


Constructor & Destructor Documentation

BazisLib::DDK::IrpQueue::IrpQueue (  ) 

BazisLib::DDK::IrpQueue::~IrpQueue (  ) 


Member Function Documentation

PIRP BazisLib::DDK::IrpQueue::DequeuePacket ( void **  ppContext  ) 

Dequeues a packet from the queue. If the queue is empty, waits for a new packet to be enqueued.

Returns:
The method returns NULL only if the queue was shut down AND there are no more enqueued packets left. That way, shutdown operation does not cause any packet to be lost.

bool BazisLib::DDK::IrpQueue::EnqueuePacket ( PIRP  pIrp,
void *  pContext 
)

Adds a new packet to the end of the queue and signals the semaphore.

Returns:
The method returns false if the queue was shut down using Shutdown() method. In other case the method returns true.

int BazisLib::DDK::IrpQueue::GetPacketCount (  )  [inline]

bool BazisLib::DDK::IrpQueue::IsShutDown (  )  [inline]

void* BazisLib::DDK::IrpQueue::operator new ( unsigned  size  )  [inline]

void BazisLib::DDK::IrpQueue::Shutdown (  )  [inline]

Shuts down the IRP queue. A queue that is shut down fails to enqueue packets

Here is the call graph for this function:


Member Data Documentation


The documentation for this class was generated from the following file:
SourceForge.net Logo