29ers::LocalStream::instance()
41ers::LocalStream::LocalStream()
46ers::LocalStream::~LocalStream()
48 remove_issue_catcher();
52ers::LocalStream::remove_issue_catcher()
54 std::unique_ptr<std::thread> catcher;
56 std::unique_lock lock(m_mutex);
57 if (!m_issue_catcher_thread.get()) {
61 m_condition.notify_one();
62 catcher.swap(m_issue_catcher_thread);
69ers::LocalStream::thread_wrapper()
71 std::unique_lock lock(m_mutex);
72 m_catcher_thread_id = std::this_thread::get_id();
73 while (!m_terminated) {
74 m_condition.wait(lock, [
this]() {
return !m_issues.empty() || m_terminated; });
76 while (!m_terminated && !m_issues.empty()) {
81 m_issue_catcher(*issue);
86 m_catcher_thread_id = {};
91ers::LocalStream::set_issue_catcher(
const std::function<
void(
const ers::Issue&)>& catcher)
93 std::unique_lock lock(m_mutex);
94 if (m_issue_catcher_thread.get()) {
95 throw ers::IssueCatcherAlreadySet(
ERS_HERE);
97 m_issue_catcher = catcher;
98 m_issue_catcher_thread.reset(
new std::thread(std::bind(&ers::LocalStream::thread_wrapper,
this)));
106 if (m_issue_catcher_thread.get() && m_catcher_thread_id != std::this_thread::get_id()) {
109 std::unique_lock lock(m_mutex);
110 m_issues.push(clone);
111 m_condition.notify_one();
113 StreamManager::instance().report_issue(
type, issue);
118ers::LocalStream::error(
const ers::Issue& issue)
124ers::LocalStream::fatal(
const ers::Issue& issue)
130ers::LocalStream::warning(
const ers::Issue& issue)
Implements issue catcher lifetime management.
Base class for any user define issue.
virtual Issue * clone() const =0
ers::Severity set_severity(ers::Severity severity) const