Exemple #1
0
ThreadPool::ThreadPool(int initThreads, int maxThreads) {
	logger = Logger::getLogger("ThreadPool");
	this->lowp = -1;
	this->highp = -1;
	this->console = false;
	this->initThreads = initThreads;
	this->maxThreads = maxThreads;
	wpool = new TaskPool;
	wpool->console = console;
	tpool = new vector<PoolThread*> ;
	for (int i = 0; i < initThreads; i++) {
		PoolThread *thread = new PoolThread();
		thread->console = console;
		thread->execute();
		tpool->push_back(thread);
	}
	poller = new Thread(&ThreadPool::poll, this);
}
Exemple #2
0
void ThreadPool::init(int initThreads, int maxThreads,bool console)
{
	this->console = console;
	this->lowp = -1;
	this->highp = -1;
	this->initThreads = initThreads;
	this->maxThreads = maxThreads;
	wpool = new TaskPool;
	wpool->console = console;
	tpool = new vector<PoolThread*> ;
	for (int i = 0; i < initThreads; i++) {
		PoolThread *thread = new PoolThread();
		thread->console = console;
		thread->execute();
		tpool->push_back(thread);
	}
	poller = new Thread(&ThreadPool::poll, this);
}
Exemple #3
0
void ThreadPool::initializeThreads()
{
	if(runFlag)return;
	wpool = new TaskPool;
	wpool->console = console;
	tpool = new vector<PoolThread*>;
	for (int i = 0; i < initThreads; i++) {
		PoolThread *thread = new PoolThread(console);
		thread->execute();
		tpool->push_back(thread);
	}
	runFlag = true;
	poller = new Thread(&ThreadPool::poll, this);
	wpool->start();
	pollerStarted = false;
	complete = false;
	m_mutex = new ConditionMutex ;
}
Exemple #4
0
ThreadPool::ThreadPool(int initThreads, int maxThreads, int lowp, int highp,bool console) {
	this->console = console;
	if (lowp > highp)
		throw "Low Priority should be less than Highest Priority";
	logger = Logger::getLogger("ThreadPool");
	this->initThreads = initThreads;
	this->maxThreads = maxThreads;
	this->lowp = lowp;
	this->highp = highp;
	tpool = new vector<PoolThread*> ;
	wpool = new TaskPool;
	wpool->console = console;
	for (int i = 0; i < initThreads; i++) {
		PoolThread *thread = new PoolThread();
		thread->console = console;
		thread->execute();
		tpool->push_back(thread);
	}
	poller = new Thread(&ThreadPool::poll, this);
	prioritypooling = true;
}