Home > Web Site Updates > ThreadPoolWrappers v1.0

ThreadPoolWrappers v1.0

March 4, 2018

Included in my W3MFC download is a custom thread pool implementation which I wrote many years ago, but since Windows Vista, Microsoft have implemented a new Thread Pool API which I have always wanted to take a look at. This download provides a complete C++ wrapper for the various components of the Thread Pool API. It is based in part on the Kenny Kerr articles on the MSDN magazine about the thread pool from August to December 2011 (https://msdn.microsoft.com/en-ca/magazine/hh335066.aspx, https://msdn.microsoft.com/en-us/magazine/hh394144.aspx, https://msdn.microsoft.com/en-us/magazine/hh456398.aspx, https://msdn.microsoft.com/magazine/hh547107.aspx & https://msdn.microsoft.com/magazine/hh580731.aspx). These wrapper classes also provide an implementation of the Thread Pool sample as provided on the blog post article at http://www.dorodnic.com/blog/2015/10/17/windows-threadpool.

The classes provided are: ThreadPoolWrappers::CCleanupGroup, ThreadPoolWrappers::CEnvironment, ThreadPoolWrappers::CIO, ThreadPoolWrappers::CPool, ThreadPoolWrappers::CThreadPool, ThreadPoolWrappers::CTimer, ThreadPoolWrappers::CWait & ThreadPoolWrappers::CWork.

CCleanupGroup provides a class based encapsulation of a Thread Pool cleanup group as represented by a PTP_CLEANUP_GROUP.

CEnvironment provides a class based encapsulation of a Thread Pool TP_CALLBACK_ENVIRON structure.

CIO provides a class based encapsulation of a Thread Pool IO callback as represented by a PTP_IO.

CPool provides a class based encapsulation of a Thread Pool pool as represented by a PTP_POOL.

CThreadPool provides a implementation of a thread pool based on the blog post article at http://www.dorodnic.com/blog/2015/10/17/windows-threadpool. It works with the default process thread pool or an explicit thread pool and provides cleanup via CEnvironment and CCleanupGroup member variables.

CTimer provides a class based encapsulation of a Thread Pool timer callback as represented by a PTP_TIMER.

CWait provides a class based encapsulation of a Thread Pool wait callback as represented by a PTP_WAIT.

CWork provides a class based encapsulation of a Thread Pool work callback as represented by a PTP_WORK.

Features

  • Provides a complete RAII wrapper for the Windows Thread Pool.
  • All the code is provided in a single C++ Header only module of "ThreadPoolWrappers.h" .
  • All the code clean compiles at warning level 4, is /analyze and /permissive- clean and includes ASCII, Unicode, x86 and x64 built configurations.
  • The classes have been tested only on VC 2017 but should be compilable on earlier versions of Visual C++.
  • The CIO, CTimer, CWait & CWork classes provide optional RAII cleanup via an bAutoRelease parameter. This is modeled on the MFC COleDispatchDriver class and means that the classes can be used in conjunction with the default process thread pool and thread pools created using a cleanup group e.g. ThreadPoolWrappers::CThreadPool
Advertisements
Categories: Web Site Updates
%d bloggers like this: