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 <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stack>
|
#include <deque>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
@ -100,7 +100,7 @@ using std::list;
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::multimap;
|
using std::multimap;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
using std::stack;
|
using std::deque;
|
||||||
|
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ ThreadPool::~ThreadPool(void)
|
||||||
void ThreadPool::EnqueueTask(Task task)
|
void ThreadPool::EnqueueTask(Task task)
|
||||||
{
|
{
|
||||||
unique_lock<mutex> lock(m_Lock);
|
unique_lock<mutex> lock(m_Lock);
|
||||||
m_Tasks.push(task);
|
m_Tasks.push_back(task);
|
||||||
m_CV.notify_one();
|
m_CV.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ void ThreadPool::WorkerThreadProc(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
task = m_Tasks.top();
|
task = m_Tasks.front();
|
||||||
m_Tasks.pop();
|
m_Tasks.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
task();
|
task();
|
||||||
|
|
|
@ -23,7 +23,7 @@ private:
|
||||||
mutex m_Lock;
|
mutex m_Lock;
|
||||||
condition_variable m_CV;
|
condition_variable m_CV;
|
||||||
|
|
||||||
stack<Task> m_Tasks;
|
deque<Task> m_Tasks;
|
||||||
|
|
||||||
thread_group m_Threads;
|
thread_group m_Threads;
|
||||||
bool m_Alive;
|
bool m_Alive;
|
||||||
|
|
|
@ -29,8 +29,10 @@
|
||||||
|
|
||||||
#include <i2-base.h>
|
#include <i2-base.h>
|
||||||
|
|
||||||
|
#include <stack>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
using std::stack;
|
||||||
using std::istream;
|
using std::istream;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::cin;
|
using std::cin;
|
||||||
|
|
Loading…
Reference in New Issue