DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
LocalStream.hpp
Go to the documentation of this file.
1/*
2 * DUNE DAQ modification notice:
3 * This file has been modified from the original ATLAS ers source for the DUNE DAQ project.
4 * Fork baseline commit: 8267df82a4f6fe6bf02c4014923eba19eddc4614 (2020-04-14).
5 * Renamed since fork: yes (from ers/LocalStream.h to include/ers/LocalStream.hpp).
6 *
7 * Original copyright:
8 * Copyright (C) 2001-2020 CERN for the benefit of the ATLAS collaboration.
9 * Licensed under the Apache License, Version 2.0.
10 */
11
12#ifndef ERS_LOCAL_STREAM_H
13#define ERS_LOCAL_STREAM_H
14
15/*
16 * LocalStream.h
17 * ers
18 *
19 * Created by Serguei Kolos on 21.11.05.
20 * Copyright 2005 CERN. All rights reserved.
21 *
22 */
23
28
29#include <condition_variable>
30#include <functional>
31#include <iostream>
32#include <mutex>
33#include <queue>
34#include <thread>
35
36#include <ers/Issue.hpp>
38
40 IssueCatcherAlreadySet, // issue class name
41 "Local error catcher has been already set", //
42 ERS_EMPTY // no attributes
43)
44
45namespace ers {
46class Issue;
47template<class>
48class SingletonCreator;
49
50class IssueCatcherHandler;
51
57
58class LocalStream
59{
60 friend class IssueCatcherHandler;
61 template<class>
62 friend class SingletonCreator;
63
64public:
66 static LocalStream& instance();
67
69 IssueCatcherHandler* set_issue_catcher(const std::function<void(const ers::Issue&)>& catcher);
70
71 void error(const ers::Issue& issue);
72
73 void fatal(const ers::Issue& issue);
74
75 void warning(const ers::Issue& issue);
76
77private:
78 LocalStream();
79 ~LocalStream();
80
81 void remove_issue_catcher();
82
83 void report_issue(ers::severity type, const ers::Issue& issue);
84
85 void thread_wrapper();
86
87private:
88 std::function<void(const ers::Issue&)> m_issue_catcher;
89 std::unique_ptr<std::thread> m_issue_catcher_thread;
90 std::mutex m_mutex;
91 std::condition_variable m_condition;
92 bool m_terminated;
93 std::queue<ers::Issue*> m_issues;
94 std::thread::id m_catcher_thread_id;
95};
96}
97
98#endif
#define ERS_EMPTY
Base class for any user define issue.
Definition Issue.hpp:76
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message_, attributes)
Definition macro.hpp:71
severity
Definition Severity.hpp:37
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34