1 #include "WorkerThread.h"
5 using namespace suanzi;
8 static const std::string TAG = "WorkerThread";
10 WorkerThread::WorkerThread(const std::string& name)
12 , m_thread (thread(&WorkerThread::run, this))
16 WorkerThread::~WorkerThread()
20 void WorkerThread::run()
22 LOG_DEBUG(TAG, "start workerThread " + m_name);
25 unique_lock<mutex> l(m_mutex);
26 if (!m_queue.empty()){
27 workItem = m_queue.front();
31 LOG_DEBUG(TAG, " ------ Queue Size: " << m_queue.size());
36 LOG_DEBUG(TAG, "End workerThread " + m_name);
39 void WorkerThread::enqueue(WorkItemPtr item)
41 unique_lock<mutex> l(m_mutex);
46 void WorkerThread::enqueue(WorkItem* w)