29ers::LocalStream::instance()
41ers::LocalStream::LocalStream( )
42 : m_terminated( false )
45ers::LocalStream::~LocalStream( )
47 remove_issue_catcher();
51ers::LocalStream::remove_issue_catcher( )
53 std::unique_ptr<std::thread> catcher;
55 std::unique_lock lock( m_mutex );
56 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 )
75 m_condition.wait( lock, [
this](){
return !m_issues.empty() || m_terminated;} );
77 while( !m_terminated && !m_issues.empty() )
83 m_issue_catcher( *issue );
88 m_catcher_thread_id = {};
93ers::LocalStream::set_issue_catcher(
const std::function<
void (
const ers::Issue & )> & catcher )
95 std::unique_lock lock( m_mutex );
96 if ( m_issue_catcher_thread.get() )
98 throw ers::IssueCatcherAlreadySet(
ERS_HERE );
100 m_issue_catcher = catcher;
101 m_issue_catcher_thread.reset(
new std::thread( std::bind( &ers::LocalStream::thread_wrapper,
this ) ) );
109 if ( m_issue_catcher_thread.get() && m_catcher_thread_id != std::this_thread::get_id() )
113 std::unique_lock lock( m_mutex );
114 m_issues.push( clone );
115 m_condition.notify_one();
119 StreamManager::instance().report_issue(
type, issue );
124ers::LocalStream::error(
const ers::Issue & issue )
130ers::LocalStream::fatal(
const ers::Issue & issue )
136ers::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
std::string join(const C &strings, const std::string &delimiter)
Converts a vector of strings in a delimiter-separated string.