int ServerLiason::ExecuteThread(void* data) { while (hasStarted) { if (!executeQueue->empty()) { CommandPacket* packet = executeQueue->pop(); packet->Execute(); delete packet; packet = nullptr; } } return 0; }
int pool_worker_function(void *data) { WorkerData *wd = (WorkerData*)data; ThreadPool *pool = wd->pool; int index = wd->threadIndex; pool->incActiveThreads(); CommandPacket* item = pool->workQue.pop(); //std::cout << "thread " << index << " gets work item " << item.workFunc << std::endl; while (item) { item->Execute(); item = pool->workQue.pop(); //std::cout << "thread gets work item " << item.workFunc << std::endl; } std::cout << "worker decrementing thread count\n"; pool->decActiveThreads(index); std::cout << "worker terminating\n"; return 0; }