Kurlyk
Loading...
Searching...
No Matches
print_utils.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef KURLYK_HEADER_KURLYK_UTILS_PRINT_UTILS_HPP_INCLUDED
3#define KURLYK_HEADER_KURLYK_UTILS_PRINT_UTILS_HPP_INCLUDED
4
7
8#define KURLYK_PRINT kurlyk::utils::ThreadSafePrintStream{}
9
10namespace kurlyk {
11namespace utils {
12
14 class ThreadSafePrintStream : public std::ostringstream {
15 public:
17
19 get_instance().print(this->str());
20 }
21
22 private:
24 public:
25 void print(const std::string &str) {
26 std::lock_guard<std::mutex> guard(m_mutex_print);
27 std::cout << str;
28 }
29
30 private:
31 std::mutex m_mutex_print;
32 };
33
35 static PrintStream instance;
36 return instance;
37 }
38 };
39
40} // namespace utils
41} // namespace kurlyk
42
43#endif // KURLYK_HEADER_KURLYK_UTILS_PRINT_UTILS_HPP_INCLUDED
static PrintStream & get_instance()
Primary namespace for the Kurlyk library, encompassing initialization, request management,...