diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-02-24 13:37:17 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-02-24 13:37:17 +0100 |
commit | 1387a04e605c3c511e2e4fc764eb6434b9837ef8 (patch) | |
tree | 6c89af8032bcaa2982bb8e7e9e246fc641f7c4e0 /src | |
parent | ebe96d69b44d73875f922a7fc59da02695969b00 (diff) | |
download | dabmod-1387a04e605c3c511e2e4fc764eb6434b9837ef8.tar.gz dabmod-1387a04e605c3c511e2e4fc764eb6434b9837ef8.tar.bz2 dabmod-1387a04e605c3c511e2e4fc764eb6434b9837ef8.zip |
Log: replace spsc queue by Threadsafequeue
The function pushing messages into the queue gets called from more than one
thread, which is illegal according to boost::lockfree documentation.
Diffstat (limited to 'src')
-rw-r--r-- | src/Log.cpp | 4 | ||||
-rw-r--r-- | src/Log.h | 6 |
2 files changed, 3 insertions, 7 deletions
diff --git a/src/Log.cpp b/src/Log.cpp index 4780f58..0792fcf 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -77,9 +77,7 @@ void Logger::io_process() set_thread_name("logger"); while (1) { log_message_t m; - while (m_message_queue.pop(m) == false) { - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } + m_message_queue.wait_and_pop(m); auto message = m.message; @@ -43,7 +43,7 @@ #include <map> #include <mutex> #include <thread> -#include <boost/lockfree/spsc_queue.hpp> +#include "ThreadsafeQueue.h" #define SYSLOG_IDENT "ODR-DabMod" #define SYSLOG_FACILITY LOG_LOCAL0 @@ -179,9 +179,7 @@ class Logger { private: std::list<LogBackend*> backends; - boost::lockfree::spsc_queue< - log_message_t, - boost::lockfree::capacity<80> > m_message_queue; + ThreadsafeQueue<log_message_t> m_message_queue; std::thread m_io_thread; std::mutex m_cerr_mutex; }; |