DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
LocalStream.hpp
Go to the documentation of this file.
1#ifndef ERS_LOCAL_STREAM_H
2#define ERS_LOCAL_STREAM_H
3
4/*
5 * LocalStream.h
6 * ers
7 *
8 * Created by Serguei Kolos on 21.11.05.
9 * Copyright 2005 CERN. All rights reserved.
10 *
11 */
12
18#include <condition_variable>
19#include <functional>
20#include <iostream>
21#include <queue>
22#include <mutex>
23#include <thread>
24
25#include <ers/Issue.hpp>
27
28ERS_DECLARE_ISSUE( ers, // namespace
29 IssueCatcherAlreadySet, // issue class name
30 "Local error catcher has been already set", //
31 ERS_EMPTY // no attributes
32 )
33
34namespace ers
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}
87
88#endif
89
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_EMPTY
Base class for any user define issue.
Definition Issue.hpp:69
severity
Definition Severity.hpp:26
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34