Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/log/sinks/async_frontend.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 /* | 1 /* |
2 * Copyright Andrey Semashev 2007 - 2013. | 2 * Copyright Andrey Semashev 2007 - 2015. |
3 * Distributed under the Boost Software License, Version 1.0. | 3 * Distributed under the Boost Software License, Version 1.0. |
4 * (See accompanying file LICENSE_1_0.txt or copy at | 4 * (See accompanying file LICENSE_1_0.txt or copy at |
5 * http://www.boost.org/LICENSE_1_0.txt) | 5 * http://www.boost.org/LICENSE_1_0.txt) |
6 */ | 6 */ |
7 /*! | 7 /*! |
28 #include <boost/bind.hpp> | 28 #include <boost/bind.hpp> |
29 #include <boost/static_assert.hpp> | 29 #include <boost/static_assert.hpp> |
30 #include <boost/smart_ptr/shared_ptr.hpp> | 30 #include <boost/smart_ptr/shared_ptr.hpp> |
31 #include <boost/smart_ptr/make_shared_object.hpp> | 31 #include <boost/smart_ptr/make_shared_object.hpp> |
32 #include <boost/thread/locks.hpp> | 32 #include <boost/thread/locks.hpp> |
33 #include <boost/thread/mutex.hpp> | 33 #include <boost/thread/recursive_mutex.hpp> |
34 #include <boost/thread/thread.hpp> | 34 #include <boost/thread/thread.hpp> |
35 #include <boost/thread/condition_variable.hpp> | 35 #include <boost/thread/condition_variable.hpp> |
36 #include <boost/log/exceptions.hpp> | 36 #include <boost/log/exceptions.hpp> |
37 #include <boost/log/detail/locking_ptr.hpp> | 37 #include <boost/log/detail/locking_ptr.hpp> |
38 #include <boost/log/detail/parameter_tools.hpp> | 38 #include <boost/log/detail/parameter_tools.hpp> |
84 * to the backend in this dedicated thread only. | 84 * to the backend in this dedicated thread only. |
85 */ | 85 */ |
86 template< typename SinkBackendT, typename QueueingStrategyT = unbounded_fifo_queue > | 86 template< typename SinkBackendT, typename QueueingStrategyT = unbounded_fifo_queue > |
87 class asynchronous_sink : | 87 class asynchronous_sink : |
88 public aux::make_sink_frontend_base< SinkBackendT >::type, | 88 public aux::make_sink_frontend_base< SinkBackendT >::type, |
89 private boost::log::aux::locking_ptr_counter_base, | |
90 public QueueingStrategyT | 89 public QueueingStrategyT |
91 { | 90 { |
92 typedef typename aux::make_sink_frontend_base< SinkBackendT >::type base_type; | 91 typedef typename aux::make_sink_frontend_base< SinkBackendT >::type base_type; |
93 typedef QueueingStrategyT queue_base_type; | 92 typedef QueueingStrategyT queue_base_type; |
94 | 93 |
95 private: | 94 private: |
96 //! Backend synchronization mutex type | 95 //! Backend synchronization mutex type |
97 typedef boost::mutex backend_mutex_type; | 96 typedef boost::recursive_mutex backend_mutex_type; |
98 //! Frontend synchronization mutex type | 97 //! Frontend synchronization mutex type |
99 typedef typename base_type::mutex_type frontend_mutex_type; | 98 typedef typename base_type::mutex_type frontend_mutex_type; |
100 | 99 |
101 //! A scope guard that implements thread ID management | 100 //! A scope guard that implements thread ID management |
102 class scoped_thread_id | 101 class scoped_thread_id |
185 //! \endcond | 184 //! \endcond |
186 | 185 |
187 #ifndef BOOST_LOG_DOXYGEN_PASS | 186 #ifndef BOOST_LOG_DOXYGEN_PASS |
188 | 187 |
189 //! A pointer type that locks the backend until it's destroyed | 188 //! A pointer type that locks the backend until it's destroyed |
190 typedef boost::log::aux::locking_ptr< sink_backend_type > locked_backend_ptr; | 189 typedef boost::log::aux::locking_ptr< sink_backend_type, backend_mutex_type > locked_backend_ptr; |
191 | 190 |
192 #else // BOOST_LOG_DOXYGEN_PASS | 191 #else // BOOST_LOG_DOXYGEN_PASS |
193 | 192 |
194 //! A pointer type that locks the backend until it's destroyed | 193 //! A pointer type that locks the backend until it's destroyed |
195 typedef implementation_defined locked_backend_ptr; | 194 typedef implementation_defined locked_backend_ptr; |
269 /*! | 268 /*! |
270 * Locking accessor to the attached backend | 269 * Locking accessor to the attached backend |
271 */ | 270 */ |
272 locked_backend_ptr locked_backend() | 271 locked_backend_ptr locked_backend() |
273 { | 272 { |
274 return locked_backend_ptr( | 273 return locked_backend_ptr(m_pBackend, m_BackendMutex); |
275 m_pBackend, | |
276 static_cast< boost::log::aux::locking_ptr_counter_base& >(*this)); | |
277 } | 274 } |
278 | 275 |
279 /*! | 276 /*! |
280 * Enqueues the log record to the backend | 277 * Enqueues the log record to the backend |
281 */ | 278 */ |
423 void start_feeding_thread() | 420 void start_feeding_thread() |
424 { | 421 { |
425 boost::thread(boost::bind(&asynchronous_sink::run, this)).swap(m_DedicatedFeedingThread); | 422 boost::thread(boost::bind(&asynchronous_sink::run, this)).swap(m_DedicatedFeedingThread); |
426 } | 423 } |
427 | 424 |
428 // locking_ptr_counter_base methods | |
429 void lock() { m_BackendMutex.lock(); } | |
430 bool try_lock() { return m_BackendMutex.try_lock(); } | |
431 void unlock() { m_BackendMutex.unlock(); } | |
432 | |
433 //! The record feeding loop | 425 //! The record feeding loop |
434 void do_feed_records() | 426 void do_feed_records() |
435 { | 427 { |
436 while (!m_StopRequested) | 428 while (!m_StopRequested) |
437 { | 429 { |
438 record_view rec; | 430 record_view rec; |
439 register bool dequeued = false; | 431 bool dequeued = false; |
440 if (!m_FlushRequested) | 432 if (!m_FlushRequested) |
441 dequeued = queue_base_type::try_dequeue_ready(rec); | 433 dequeued = queue_base_type::try_dequeue_ready(rec); |
442 else | 434 else |
443 dequeued = queue_base_type::try_dequeue(rec); | 435 dequeued = queue_base_type::try_dequeue(rec); |
444 | 436 |