ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkThreadLogger.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkThreadLogger_h
19#define itkThreadLogger_h
20
21#include "itkLogger.h"
22#include <mutex>
23#include <atomic>
24
25#include <string>
26#include <queue>
27#include <thread>
28
29namespace itk
30{
40
41class ITKCommon_EXPORT ThreadLogger : public Logger
42{
43public:
48
50 itkOverrideGetNameOfClassMacro(ThreadLogger);
51
53 itkNewMacro(Self);
54
56
58
59 using DelayType = unsigned int;
60
70
74 void
76
81 GetPriorityLevel() const override;
82
83 void
85
87 GetLevelForFlushing() const override;
88
92 virtual void
94
98 virtual DelayType
99 GetDelay() const;
100
102 void
103 AddLogOutput(OutputType * output) override;
104
105 void
106 Write(PriorityLevelEnum level, const std::string & content) override;
107
108 void
109 Flush() override;
110
111protected:
114
116 ~ThreadLogger() override;
117
119 void
120 PrintSelf(std::ostream & os, Indent indent) const override;
121
122 void
124
125private:
126 void
128
129 std::thread m_Thread{};
130
131 std::atomic<bool> m_TerminationRequested{};
132
133 std::queue<OperationType> m_OperationQ{};
134
135 std::queue<std::string> m_MessageQ{};
136
137 std::queue<PriorityLevelEnum> m_LevelQ{};
138
139 std::queue<OutputType::Pointer> m_OutputQ{};
140
141 mutable std::mutex m_Mutex{};
142
144
145}; // class ThreadLogger
146} // namespace itk
147
148#endif // itkThreadLogger_h
Control indentation during Print() invocation.
Definition itkIndent.h:50
LoggerBaseEnums::PriorityLevel PriorityLevelEnum
MultipleLogOutput::OutputType OutputType
Implements transparent reference counting.
SmartPointer< const Self > ConstPointer
~ThreadLogger() override
std::queue< PriorityLevelEnum > m_LevelQ
std::atomic< bool > m_TerminationRequested
void SetPriorityLevel(PriorityLevelEnum level) override
void Flush() override
Logger::OutputType OutputType
void SetLevelForFlushing(PriorityLevelEnum level) override
virtual DelayType GetDelay() const
SmartPointer< Self > Pointer
unsigned int DelayType
void AddLogOutput(OutputType *output) override
std::queue< std::string > m_MessageQ
PriorityLevelEnum GetPriorityLevel() const override
Logger::PriorityLevelEnum PriorityLevelEnum
void Write(PriorityLevelEnum level, const std::string &content) override
void PrintSelf(std::ostream &os, Indent indent) const override
PriorityLevelEnum GetLevelForFlushing() const override
virtual void SetDelay(DelayType delay)
std::queue< OperationType > m_OperationQ
std::queue< OutputType::Pointer > m_OutputQ
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....