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

CIOPool Class Reference
[Win32 Threading primitivesAsynchronous I/O]

Inheritance diagram for CIOPool:
Collaboration diagram for CIOPool:

List of all members.


Detailed Description

An I/O thread pool implementing IIOPool.

Public Types

typedef unsigned short ThreadCount
typedef ULONG_PTR ThreadIdentifier
typedef void * DeviceHandle

Public Member Functions

 CIOPool (ThreadCount numThreads=0)
 Create an I/O pool with the specified number of threads (0 = 2 x the number of CPUs that you have) which has the specified threadIdentifier. Note that you only need to change the thread identifier if you create more than one instance of CIOPool and you do not wish for the threads in each instance to be treated as equals.
 CIOPool (JetByteTools::Core::IMonitorThreadPool &monitor, ThreadCount numThreads=0)
 Create an I/O pool with the provided monitor and the specified number of threads (0 = 2 x the number of CPUs that you have) which has the specified threadIdentifier. Note that you only need to change the thread identifier if you create more than one instance of CIOPool and you do not wish for the threads in each instance to be treated as equals.
 CIOPool (const CIOPool &rhs)
 ~CIOPool () override
CIOPooloperator= (const CIOPool &rhs)
void SetThreadPriority (int priority)
 Sets the priority of the thread pool worker threads to the supplied value. Note that this must be called before calling Start() for it to have an effect.
void SetThreadName (const JetByteTools::Core::_tstring &threadName)
 Sets the name of the worker thread as displayed in the Visual Studio debugger to the supplied name. By default the constructor sets the name of the thread to "IOPool". Note that this must be called before calling Start() for it to have an effect.
void Dispatch (IHandler &handler, DWORD userData) override
void Dispatch (IHandler &handler, IBuffer *pBuffer, DWORD numberOfBytes) override
 Dispatch a buffer and a handler to the pool.
void Start () override
 Start the threads in the thread pool.
void BeginShutdown () override
 Request that the threads shut themselves down once they complete working on the current work items in the queue.
void WaitForShutdownToComplete () override
 Wait for all the threads to finish.
void ScheduleOperation (IRefCountedHandler &handler) override
ThreadCount GetNumberOfThreads () const override
 Returns the number of threads in the pool.
void AssociateDevice (HANDLE hDevice, IHandler &handler) const override
 Associate a HANDLE with a handler. I/O completion packets that the HANDLE generates will be handled by the handler.
bool TryAssociateDevice (HANDLE hDevice, IHandler &handler) const override
 Attempt to associate a HANDLE with a handler. I/O completion packets that the HANDLE generates will be handled by the handler. Returns false, rather than throwing an exception, if an error occurs, you can call GetLastError() to retrieve the error message;.
bool ThreadIsInPool () const override
 Returns true if the calling thread is a member of the thread I/O thread pool. The I/O pool uses a TLS slot to store a, non-zero, identifier for all the threads that make up the pool. Some I/O operations can be performed more efficiently if done on a thread that is known to be part of the I/O pool.
void JoinLogicalThreadGroup () const override
 Allows an arbitrary thread to join the thread pool's logical group. This can be used by threads that will 'never exit' during the program lifetime to be treated as I/O threads for the purposes of not needing to marshal I/O requests to the I/O pool before issuing them. Use with care, on pre-Vista boxes I/O is cancelled if the issuing thread exits before it completes.
HANDLE GetHandle () const override
 Obtains the handle to the underlying IOCP, use with care!!! We only need to expose this because the SetInformationJobObject function needs it... This is a really NASTY hack as the pool need not be based on a physical IOCP, if it isn't then this method will return INVALID_HANDLE_VALUE.
DWORD AssociateDeviceWithIOSubSystem (DeviceHandle device, IHandler &handler, const DWORD) override
virtual DWORD AssociateDeviceWithIOSubSystem (DeviceHandle device, IHandler &handler, DWORD flags)=0
DWORD ModifyDeviceAssociation (DeviceHandle, IHandler &, DWORD) override
virtual DWORD ModifyDeviceAssociation (DeviceHandle device, IHandler &handler, DWORD flags)=0
DWORD DisassociateDeviceFromIOSubSystem (DeviceHandle, DWORD) override
virtual DWORD DisassociateDeviceFromIOSubSystem (DeviceHandle device, DWORD flags)=0
bool IsIOThread () const override

Protected Attributes

JetByteTools::Win32::CIOCompletionPort m_iocp

Classes

class  WorkerThread
 A worker thread class for the CIOPool. More...

Member Typedef Documentation

typedef unsigned short ThreadCount [inherited]

Reimplemented from IIOPool.

typedef ULONG_PTR ThreadIdentifier [inherited]

typedef void* DeviceHandle [inherited]


Constructor & Destructor Documentation

CIOPool ( ThreadCount  numThreads = 0  )  [explicit]

Create an I/O pool with the specified number of threads (0 = 2 x the number of CPUs that you have) which has the specified threadIdentifier. Note that you only need to change the thread identifier if you create more than one instance of CIOPool and you do not wish for the threads in each instance to be treated as equals.

CIOPool ( JetByteTools::Core::IMonitorThreadPool monitor,
ThreadCount  numThreads = 0 
) [explicit]

Create an I/O pool with the provided monitor and the specified number of threads (0 = 2 x the number of CPUs that you have) which has the specified threadIdentifier. Note that you only need to change the thread identifier if you create more than one instance of CIOPool and you do not wish for the threads in each instance to be treated as equals.

CIOPool ( const CIOPool rhs  ) 

~CIOPool (  )  [override]

Reimplemented in CIOPool.


Member Function Documentation

CIOPool& operator= ( const CIOPool rhs  ) 

void SetThreadPriority ( int  priority  )  [inherited]

Sets the priority of the thread pool worker threads to the supplied value. Note that this must be called before calling Start() for it to have an effect.

void SetThreadName ( const JetByteTools::Core::_tstring threadName  )  [inherited]

Sets the name of the worker thread as displayed in the Visual Studio debugger to the supplied name. By default the constructor sets the name of the thread to "IOPool". Note that this must be called before calling Start() for it to have an effect.

void Dispatch ( IHandler handler,
DWORD  userData 
) [override, virtual, inherited]

void Dispatch ( IHandler handler,
IBuffer *  pBuffer,
DWORD  numberOfBytes 
) [override, virtual, inherited]

Dispatch a buffer and a handler to the pool.

Implements IIOPool.

void Start (  )  [override, virtual, inherited]

Start the threads in the thread pool.

Implements IIOSubSystem.

void BeginShutdown (  )  [override, virtual, inherited]

Request that the threads shut themselves down once they complete working on the current work items in the queue.

Implements IIOSubSystem.

void WaitForShutdownToComplete (  )  [override, virtual, inherited]

Wait for all the threads to finish.

Implements IIOSubSystem.

void ScheduleOperation ( IRefCountedHandler handler  )  [override, virtual, inherited]

Implements IIOPool.

CIOPoolBase::ThreadCount GetNumberOfThreads (  )  const [override, virtual, inherited]

Returns the number of threads in the pool.

Implements IIOPool.

void AssociateDevice ( HANDLE  hDevice,
IHandler handler 
) const [override, virtual, inherited]

Associate a HANDLE with a handler. I/O completion packets that the HANDLE generates will be handled by the handler.

Implements IIOPool.

bool TryAssociateDevice ( HANDLE  hDevice,
IHandler handler 
) const [override, virtual, inherited]

Attempt to associate a HANDLE with a handler. I/O completion packets that the HANDLE generates will be handled by the handler. Returns false, rather than throwing an exception, if an error occurs, you can call GetLastError() to retrieve the error message;.

Implements IIOPool.

bool ThreadIsInPool (  )  const [override, virtual, inherited]

Returns true if the calling thread is a member of the thread I/O thread pool. The I/O pool uses a TLS slot to store a, non-zero, identifier for all the threads that make up the pool. Some I/O operations can be performed more efficiently if done on a thread that is known to be part of the I/O pool.

Implements IIOPool.

void JoinLogicalThreadGroup (  )  const [override, virtual, inherited]

Allows an arbitrary thread to join the thread pool's logical group. This can be used by threads that will 'never exit' during the program lifetime to be treated as I/O threads for the purposes of not needing to marshal I/O requests to the I/O pool before issuing them. Use with care, on pre-Vista boxes I/O is cancelled if the issuing thread exits before it completes.

Implements IIOPool.

HANDLE GetHandle (  )  const [override, virtual, inherited]

Obtains the handle to the underlying IOCP, use with care!!! We only need to expose this because the SetInformationJobObject function needs it... This is a really NASTY hack as the pool need not be based on a physical IOCP, if it isn't then this method will return INVALID_HANDLE_VALUE.

Implements IIOPool.

DWORD AssociateDeviceWithIOSubSystem ( DeviceHandle  device,
IHandler handler,
const   DWORD 
) [inline, override, inherited]

virtual DWORD AssociateDeviceWithIOSubSystem ( DeviceHandle  device,
IHandler handler,
DWORD  flags 
) [pure virtual, inherited]

DWORD ModifyDeviceAssociation ( DeviceHandle  ,
IHandler ,
DWORD   
) [inline, override, inherited]

virtual DWORD ModifyDeviceAssociation ( DeviceHandle  device,
IHandler handler,
DWORD  flags 
) [pure virtual, inherited]

DWORD DisassociateDeviceFromIOSubSystem ( DeviceHandle  ,
DWORD   
) [inline, override, inherited]

virtual DWORD DisassociateDeviceFromIOSubSystem ( DeviceHandle  device,
DWORD  flags 
) [pure virtual, inherited]

bool IsIOThread (  )  const [inline, override, virtual, inherited]


Member Data Documentation


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