Public Types | |
typedef unsigned short | ThreadCount |
typedef ULONG_PTR | ThreadIdentifier |
typedef void * | DeviceHandle |
Public Member Functions | |
CIOPoolBase (ThreadCount numThreads, const JetByteTools::Core::_tstring &threadName) | |
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. | |
CIOPoolBase (JetByteTools::Core::IMonitorThreadPool &monitor, ThreadCount numThreads, const JetByteTools::Core::_tstring &threadName) | |
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. | |
CIOPoolBase (const CIOPoolBase &rhs) | |
~CIOPoolBase () override | |
CIOPoolBase & | operator= (const CIOPoolBase &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 | 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 |
void | Dispatch (IHandler &handler, IBuffer *pBuffer, DWORD numberOfBytes) override |
Dispatch a buffer and a handler to the pool. | |
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 CIOPoolBase. More... |
typedef unsigned short ThreadCount |
Reimplemented from IIOPool.
typedef ULONG_PTR ThreadIdentifier [inherited] |
typedef void* DeviceHandle [inherited] |
CIOPoolBase | ( | ThreadCount | numThreads, | |
const JetByteTools::Core::_tstring & | threadName | |||
) |
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.
CIOPoolBase | ( | JetByteTools::Core::IMonitorThreadPool & | monitor, | |
ThreadCount | numThreads, | |||
const JetByteTools::Core::_tstring & | threadName | |||
) |
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.
CIOPoolBase | ( | const CIOPoolBase & | rhs | ) |
~CIOPoolBase | ( | ) | [override] |
CIOPoolBase& operator= | ( | const CIOPoolBase & | 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.
Implements IDispatchToWorkerThread.
void Start | ( | ) | [override, virtual] |
void BeginShutdown | ( | ) | [override, virtual] |
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] |
void ScheduleOperation | ( | IRefCountedHandler & | handler | ) | [override, virtual] |
Implements IIOPool.
CIOPoolBase::ThreadCount GetNumberOfThreads | ( | ) | const [override, virtual] |
Associate a HANDLE with a handler. I/O completion packets that the HANDLE generates will be handled by the handler.
Implements IIOPool.
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] |
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] |
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] |
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] |
Implements IAssociateDeviceWithIOSubSystem.
JetByteTools::Win32::CIOCompletionPort m_iocp [protected] |