X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fthread_pool_observer.cpp;h=7c6f1893f9201bf5a4f9f1e4d6d768bfa0299584;hb=9633f388601013d6a4de9367a307dfe647dbbaa6;hp=ded50d70f82fa510b7381ff91c802f70b8737103;hpb=09a360ce6e6b550c75c6d30502e1019a8e9f5fa6;p=metaproxy-moved-to-github.git diff --git a/src/thread_pool_observer.cpp b/src/thread_pool_observer.cpp index ded50d7..7c6f189 100644 --- a/src/thread_pool_observer.cpp +++ b/src/thread_pool_observer.cpp @@ -68,6 +68,7 @@ namespace metaproxy_1 { std::deque m_output; bool m_stop_flag; unsigned m_no_threads; + unsigned m_no_threads_waiting; }; const unsigned int queue_size_per_thread = 64; } @@ -100,6 +101,7 @@ ThreadPoolSocketObserver::ThreadPoolSocketObserver( m_p->m_stop_flag = false; m_p->m_no_threads = no_threads; + m_p->m_no_threads_waiting = 0; int i; for (i = 0; im_output.front(); m_p->m_output.pop_front(); } + + if (out) - out->result(); + { + std::ostringstream os; + { + boost::mutex::scoped_lock input_lock(m_p->m_mutex_input_data); + os << "tbusy/total " << + m_p->m_no_threads - m_p->m_no_threads_waiting << + "/" << m_p->m_no_threads + << " queue in/out " << m_p->m_input.size() << "/" + << m_p->m_output.size(); + } + out->result(os.str().c_str()); + } } } @@ -157,8 +172,10 @@ void ThreadPoolSocketObserver::run(void *p) IThreadPoolMsg *in = 0; { boost::mutex::scoped_lock input_lock(m_p->m_mutex_input_data); + m_p->m_no_threads_waiting++; while (!m_p->m_stop_flag && m_p->m_input.size() == 0) m_p->m_cond_input_data.wait(input_lock); + m_p->m_no_threads_waiting--; if (m_p->m_stop_flag) break;