This commit is contained in:
beykery
2014-04-17 14:40:56 +08:00
parent 2d86f7061e
commit bbb3986946
88 changed files with 7488 additions and 885 deletions

View File

@@ -0,0 +1,38 @@
#include "WorkThread.h"
#include "errno.h"
#include "BlockingQueue.h"
#include "Thread.h"
WorkThread::WorkThread()
{
this->q = new BlockingQueue<Thread>;
this->Start();
}
WorkThread::~WorkThread()
{
delete q;
}
void WorkThread::Run()
{
while (this->status != QUITED)
{
Thread* task = (Thread*) q->Poll();
if (task != NULL)
{
status = RUNNING;
task->Run();
delete task;
} else
{
this->status = IDLE;
sem_wait(this->sem); //等待添加新的task
}
}
}
int WorkThread::TaskCount()
{
return q->Size();
}