DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
LocalStream.hpp File Reference
#include <condition_variable>
#include <functional>
#include <iostream>
#include <queue>
#include <mutex>
#include <thread>
#include <ers/Issue.hpp>
#include <ers/IssueCatcherHandler.hpp>
Include dependency graph for LocalStream.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 ERS_DECLARE_ISSUE (ers, IssueCatcherAlreadySet, "Local error catcher has been already set", ERS_EMPTY) namespace ers
 

Function Documentation

◆ ERS_DECLARE_ISSUE()

ERS_DECLARE_ISSUE ( ers ,
IssueCatcherAlreadySet ,
"Local error catcher has been already set" ,
ERS_EMPTY  )

The LocalStream class can be used for passing issues between threads of the same process.

Author
Serguei Kolos
Version
1.2

returns the singleton

sets local issue catcher

Definition at line 28 of file LocalStream.hpp.

35{
36 class Issue;
37 template <class > class SingletonCreator;
38
39 class IssueCatcherHandler;
40
47 class LocalStream
48 {
49 friend class IssueCatcherHandler;
50 template <class > friend class SingletonCreator;
51
52 public:
53
55 static LocalStream & instance();
56
58 IssueCatcherHandler * set_issue_catcher(
59 const std::function<void ( const ers::Issue & )> & catcher );
60
61 void error( const ers::Issue & issue );
62
63 void fatal( const ers::Issue & issue );
64
65 void warning( const ers::Issue & issue );
66
67 private:
68 LocalStream( );
69 ~LocalStream( );
70
71 void remove_issue_catcher();
72
73 void report_issue( ers::severity type, const ers::Issue & issue );
74
75 void thread_wrapper();
76
77 private:
78 std::function<void ( const ers::Issue & )> m_issue_catcher;
79 std::unique_ptr<std::thread> m_issue_catcher_thread;
80 std::mutex m_mutex;
81 std::condition_variable m_condition;
82 bool m_terminated;
83 std::queue<ers::Issue *> m_issues;
84 std::thread::id m_catcher_thread_id;
85 };
86}
Base class for any user define issue.
Definition Issue.hpp:69
CTB Buffer Issue
void warning(const Issue &issue)
Definition ers.hpp:115
IssueCatcherHandler * set_issue_catcher(const std::function< void(const ers::Issue &)> &catcher)
Definition ers.hpp:60
void fatal(const Issue &issue)
Definition ers.hpp:88
severity
Definition Severity.hpp:26
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34