mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
parent
36a45059f9
commit
f4d04f8172
@ -197,13 +197,14 @@ void ThreadPool::QueueThreadProc(int tid)
|
||||
* Appends a work item to the work queue. Work items will be processed in FIFO order.
|
||||
*
|
||||
* @param callback The callback function for the work item.
|
||||
* @returns true if the item was queued, false otherwise.
|
||||
*/
|
||||
void ThreadPool::Post(const ThreadPool::WorkFunction& callback)
|
||||
bool ThreadPool::Post(const ThreadPool::WorkFunction& callback)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
if (m_Stopped)
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("ThreadPool has been stopped."));
|
||||
return false;
|
||||
|
||||
WorkItem wi;
|
||||
wi.Callback = callback;
|
||||
@ -211,6 +212,8 @@ void ThreadPool::Post(const ThreadPool::WorkFunction& callback)
|
||||
|
||||
m_WorkItems.push_back(wi);
|
||||
m_WorkCV.notify_one();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThreadPool::ManagerThreadProc(void)
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
void Stop(void);
|
||||
void Join(void);
|
||||
|
||||
void Post(const WorkFunction& callback);
|
||||
bool Post(const WorkFunction& callback);
|
||||
|
||||
private:
|
||||
enum ThreadState
|
||||
|
Loading…
x
Reference in New Issue
Block a user