Click here to Skip to main content
15,891,316 members
Articles / Programming Languages / C++

An exception safe OO thread-pool framework

Rate me:
Please Sign up or sign in to vote.
4.86/5 (62 votes)
16 May 2013CPOL7 min read 307.3K   2.7K   167  
Provides a plug in multithreaded environment, using an exception safe thread-pool and functors.
/**
 * @file
 */
#pragma once
#include <windows.h>

/**
 *	Interface to the threadpool.  
 *	This MUST be derived from with the execute method overridden to use your own custom
 *	handler.  
 * 
 *	@warning execute is declared as throwing no exceptions.  This means that you MUST deal with exceptions in the 
 *           command object.
 * 
 *	@author Peter Hancock
 *
 */
class ThreadRequest
{
public:
	ThreadRequest(){}
	virtual ~ThreadRequest(void){}
	virtual void operator()(int threadId) throw() = 0;			 ///< Must be overridden by your custom dispatch function.
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Microsoft
United States United States
Nutcase triathlete that likes doing long course triathlons. Planning on competing in the Hawaiian Ironman at some stage - in fact - just as soon as I qualify.

Comments and Discussions