The C++ framework for developing highly scalable, high performance servers on Windows platforms.

CIOCompletionPort Class Reference
[Win32 Threading primitivesWin32 I/O Completion Ports]

Collaboration diagram for CIOCompletionPort:

List of all members.


Detailed Description

A simple wrapper around the I/O Completion Port API. I/O completion ports are, essentially, thread safe queues that can control how many threads are allowed to run and process items on the queue in a way that simply isn't possible if you stay entirely in "user mode". The queue keeps the threads that are waiting in fifo order to minimise memory paging and can limit the number of 'runable'threads that it releases. See here and here for more details.

Public Member Functions

 CIOCompletionPort (DWORD maxConcurrency)
 Creates an I/O completion port with the specified maximum number of threads that the operating system can allow to concurrently process I/O completion packets for the I/O completion port.
 CIOCompletionPort (const CIOCompletionPort &rhs)
CIOCompletionPortoperator= (const CIOCompletionPort &rhs)
void AssociateDevice (HANDLE hDevice, ULONG_PTR completionKey) const
 Associate a device, represented by the supplied HANDLE, and the supplied completion key with the I/O completion port. Overlapped I/O that occurs on device will then post completion packets to the port.
bool TryAssociateDevice (HANDLE hDevice, ULONG_PTR completionKey) const
 Attempt to associate a device, represented by the supplied HANDLE, and the supplied completion key with the I/O completion port. Overlapped I/O that occurs on device will then post completion packets to the port. Returns false, rather than throwing an exception, when an error occurs, you can call GetLastError() to retrieve the error message;.
void PostStatus (ULONG_PTR completionKey, DWORD dwNumBytes=0, OVERLAPPED *pOverlapped=nullptr)
 Manually post a completion packet to the I/O completion port.
void GetStatus (ULONG_PTR *pCompletionKey, PDWORD pdwNumBytes, OVERLAPPED **ppOverlapped)
 Waits, indefinitely, for a completion packet to arrive at the port. Throws an exception on failure.
bool GetStatus (ULONG_PTR *pCompletionKey, PDWORD pdwNumBytes, OVERLAPPED **ppOverlapped, Milliseconds timeout)
 Waits, with a timeout, for a completion packet to arrive at the port. Throws an exception on failure.
bool GetStatus (ULONG_PTR *pCompletionKey, PDWORD pdwNumBytes, OVERLAPPED **ppOverlapped, DWORD *pLastError)
 Waits, indefinitely, for a completion packet to arrive at the port but returns false and the value of the last error if an error occurs.
bool GetStatus (ULONG_PTR *pCompletionKey, PDWORD pdwNumBytes, OVERLAPPED **ppOverlapped, DWORD &lastError, Milliseconds timeout)
 Waits, with a timeout, for a completion packet to arrive at the port and returns false and the value of the last error if an error occurs.
void GetStatus (OVERLAPPED_ENTRY *pEntries, ULONG &numEntries)
 Waits, indefinitely, for completion packets to arrive at the port. Throws an exception on failure.
bool GetStatus (OVERLAPPED_ENTRY *pEntries, ULONG &numEntries, Milliseconds timeout)
 Waits, with a timeout, for completion packets to arrive at the port. Throws an exception on failure.
bool GetStatus (OVERLAPPED_ENTRY *pEntries, ULONG &numEntries, DWORD *pLastError)
 Waits, indefinitely, for completion packets to arrive at the port but returns false and the value of the last error if an error occurs.
bool GetStatus (OVERLAPPED_ENTRY *pEntries, ULONG &numEntries, DWORD &lastError, Milliseconds timeout)
 Waits, with a timeout, for completion packets to arrive at the port and returns false and the value of the last error if an error occurs.
HANDLE GetHandle () const
 Obtains the handle to the underlying IOCP, use with care!!! We only need to expose this because the SetInformationJobObject function needs it...

Constructor & Destructor Documentation

CIOCompletionPort ( DWORD  maxConcurrency  )  [explicit]

Creates an I/O completion port with the specified maximum number of threads that the operating system can allow to concurrently process I/O completion packets for the I/O completion port.

CIOCompletionPort ( const CIOCompletionPort rhs  ) 


Member Function Documentation

CIOCompletionPort& operator= ( const CIOCompletionPort rhs  ) 

void AssociateDevice ( HANDLE  hDevice,
ULONG_PTR  completionKey 
) const

Associate a device, represented by the supplied HANDLE, and the supplied completion key with the I/O completion port. Overlapped I/O that occurs on device will then post completion packets to the port.

bool TryAssociateDevice ( HANDLE  hDevice,
ULONG_PTR  completionKey 
) const

Attempt to associate a device, represented by the supplied HANDLE, and the supplied completion key with the I/O completion port. Overlapped I/O that occurs on device will then post completion packets to the port. Returns false, rather than throwing an exception, when an error occurs, you can call GetLastError() to retrieve the error message;.

void PostStatus ( ULONG_PTR  completionKey,
DWORD  dwNumBytes = 0,
OVERLAPPED pOverlapped = nullptr 
)

Manually post a completion packet to the I/O completion port.

void GetStatus ( ULONG_PTR pCompletionKey,
PDWORD  pdwNumBytes,
OVERLAPPED **  ppOverlapped 
)

Waits, indefinitely, for a completion packet to arrive at the port. Throws an exception on failure.

bool GetStatus ( ULONG_PTR pCompletionKey,
PDWORD  pdwNumBytes,
OVERLAPPED **  ppOverlapped,
Milliseconds  timeout 
)

Waits, with a timeout, for a completion packet to arrive at the port. Throws an exception on failure.

bool GetStatus ( ULONG_PTR pCompletionKey,
PDWORD  pdwNumBytes,
OVERLAPPED **  ppOverlapped,
DWORD pLastError 
)

Waits, indefinitely, for a completion packet to arrive at the port but returns false and the value of the last error if an error occurs.

bool GetStatus ( ULONG_PTR pCompletionKey,
PDWORD  pdwNumBytes,
OVERLAPPED **  ppOverlapped,
DWORD lastError,
Milliseconds  timeout 
)

Waits, with a timeout, for a completion packet to arrive at the port and returns false and the value of the last error if an error occurs.

void GetStatus ( OVERLAPPED_ENTRY pEntries,
ULONG numEntries 
)

Waits, indefinitely, for completion packets to arrive at the port. Throws an exception on failure.

bool GetStatus ( OVERLAPPED_ENTRY pEntries,
ULONG numEntries,
Milliseconds  timeout 
)

Waits, with a timeout, for completion packets to arrive at the port. Throws an exception on failure.

bool GetStatus ( OVERLAPPED_ENTRY pEntries,
ULONG numEntries,
DWORD pLastError 
)

Waits, indefinitely, for completion packets to arrive at the port but returns false and the value of the last error if an error occurs.

bool GetStatus ( OVERLAPPED_ENTRY pEntries,
ULONG numEntries,
DWORD lastError,
Milliseconds  timeout 
)

Waits, with a timeout, for completion packets to arrive at the port and returns false and the value of the last error if an error occurs.

HANDLE GetHandle (  )  const

Obtains the handle to the underlying IOCP, use with care!!! We only need to expose this because the SetInformationJobObject function needs it...


Generated on Sun Sep 12 19:11:35 2021 for The Server Framework - v7.4 by doxygen 1.5.3