mirror of https://github.com/Icinga/icinga2.git
Use a FIFO queue for the tasks in the thread pool.
This commit is contained in:
parent
bd1e8b2395
commit
1d8331ecd8
|
@ -91,7 +91,7 @@
|
|||
#include <map>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <stack>
|
||||
#include <deque>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
@ -100,7 +100,7 @@ using std::list;
|
|||
using std::set;
|
||||
using std::multimap;
|
||||
using std::pair;
|
||||
using std::stack;
|
||||
using std::deque;
|
||||
|
||||
using std::stringstream;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ ThreadPool::~ThreadPool(void)
|
|||
void ThreadPool::EnqueueTask(Task task)
|
||||
{
|
||||
unique_lock<mutex> lock(m_Lock);
|
||||
m_Tasks.push(task);
|
||||
m_Tasks.push_back(task);
|
||||
m_CV.notify_one();
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ void ThreadPool::WorkerThreadProc(void)
|
|||
return;
|
||||
}
|
||||
|
||||
task = m_Tasks.top();
|
||||
m_Tasks.pop();
|
||||
task = m_Tasks.front();
|
||||
m_Tasks.pop_front();
|
||||
}
|
||||
|
||||
task();
|
||||
|
|
|
@ -23,7 +23,7 @@ private:
|
|||
mutex m_Lock;
|
||||
condition_variable m_CV;
|
||||
|
||||
stack<Task> m_Tasks;
|
||||
deque<Task> m_Tasks;
|
||||
|
||||
thread_group m_Threads;
|
||||
bool m_Alive;
|
||||
|
|
|
@ -29,8 +29,10 @@
|
|||
|
||||
#include <i2-base.h>
|
||||
|
||||
#include <stack>
|
||||
#include <fstream>
|
||||
|
||||
using std::stack;
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
using std::cin;
|
||||
|
|
Loading…
Reference in New Issue