From d3e2ec203a5cf550320caa8023ac3dd103b0be7d Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 13 Oct 2014 00:42:37 -0400 Subject: new kenlm --- klm/util/thread_pool.hh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'klm/util/thread_pool.hh') diff --git a/klm/util/thread_pool.hh b/klm/util/thread_pool.hh index 84e257ea..d1a883a0 100644 --- a/klm/util/thread_pool.hh +++ b/klm/util/thread_pool.hh @@ -1,5 +1,5 @@ -#ifndef UTIL_THREAD_POOL__ -#define UTIL_THREAD_POOL__ +#ifndef UTIL_THREAD_POOL_H +#define UTIL_THREAD_POOL_H #include "util/pcqueue.hh" @@ -18,8 +18,8 @@ template class Worker : boost::noncopyable { typedef HandlerT Handler; typedef typename Handler::Request Request; - template Worker(PCQueue &in, Construct &construct, Request &poison) - : in_(in), handler_(construct), thread_(boost::ref(*this)), poison_(poison) {} + template Worker(PCQueue &in, Construct &construct, const Request &poison) + : in_(in), handler_(construct), poison_(poison), thread_(boost::ref(*this)) {} // Only call from thread. void operator()() { @@ -30,7 +30,7 @@ template class Worker : boost::noncopyable { try { (*handler_)(request); } - catch(std::exception &e) { + catch(const std::exception &e) { std::cerr << "Handler threw " << e.what() << std::endl; abort(); } @@ -49,10 +49,10 @@ template class Worker : boost::noncopyable { PCQueue &in_; boost::optional handler_; + + const Request poison_; boost::thread thread_; - - Request poison_; }; template class ThreadPool : boost::noncopyable { @@ -92,4 +92,4 @@ template class ThreadPool : boost::noncopyable { } // namespace util -#endif // UTIL_THREAD_POOL__ +#endif // UTIL_THREAD_POOL_H -- cgit v1.2.3