MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Post

Method Post

lib/base/threadpool.hpp:55–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 */
54 template<class T>
55 bool Post(T callback, SchedulerPolicy)
56 {
57 boost::shared_lock<decltype(m_Mutex)> lock (m_Mutex);
58
59 if (m_Pool) {
60 m_Pending.fetch_add(1);
61
62 boost::asio::post(*m_Pool, [this, callback]() {
63 m_Pending.fetch_sub(1);
64
65 try {
66 callback();
67 } catch (const std::exception& ex) {
68 Log(LogCritical, "ThreadPool")
69 << "Exception thrown in event handler:\n"
70 << DiagnosticInformation(ex);
71 } catch (...) {
72 Log(LogCritical, "ThreadPool", "Exception of unknown type thrown in event handler.");
73 }
74 });
75
76 return true;
77 } else {
78 return false;
79 }
80 }
81
82 /**
83 * Returns the amount of queued tasks not started yet.

Callers 1

QueueAsyncCallbackMethod · 0.80

Calls 1

LogClass · 0.85

Tested by

no test coverage detected