17 #include <core/pubsub.h> 35 static ConsoleBuffer* instance() {
36 static auto instance =
new ConsoleBuffer();
40 void addMessage(
const string& message) {
44 std::unique_lock<mutex> guard(lock_);
46 messages_.push_back(message);
52 console_output.
publish(message);
56 void flushAndResume() {
57 vector<string> current_messages;
60 std::unique_lock<mutex> guard(lock_);
61 current_messages.swap(messages_);
65 for (
const auto& message : current_messages)
66 console_output.
publish(message);
70 ConsoleBuffer() =
default;
74 vector<string> messages_;
75 bool buffering_ =
true;
void publish(const T &value) const
Publish a new value.
Definition: pubsub.h:64