www.pudn.com > net_oss.rar > thread_pool.cc


#include "thread_pool.h"
using namespace std;

thread_pool::thread_pool(int _i, int key) : total(_i) 
{
	#ifdef __DEBUG
	cout << " Create thread pool " << endl; 
	#endif
	//create ipc queue to send/receive messages
		if((mqid = msgget(key,0))<0) 
		{
    	mqid = msgget(key, IPC_CREAT | IPC_EXCL | 0600);
    	if (mqid < 0)
    	{
            ERR_REPORT();   
    	}
    }
}

thread_pool::~thread_pool() 
{ 
	#ifdef __DEBUG
	cout << " Thread pool canceled. " << endl;
	#endif
	msgctl(mqid,IPC_RMID,0);
}