3#include "elementa/license.inc"
4#include "elementa/checks.inc"
6#ifndef ELEMENTA_UTILS_COMMANDLINE
7#define ELEMENTA_UTILS_COMMANDLINE
10#include "elementa/base/serial_channels.h"
47template <
typename Data>
55 std::chrono::time_point<std::chrono::steady_clock>
moment;
61 FastLog(
size_t capacity):log_{capacity} {}
68 bool empty(
void)
const;
71 size_t size(
void)
const;
74 void add(
const Data & data);
101template <
typename Data>
104 std::unique_lock<std::mutex> lock(logmtx_);
109template <
typename Data>
112 std::unique_lock<std::mutex> lock(
const_cast<std::mutex &
>(logmtx_));
114 return(log_.empty());
117template <
typename Data>
120 std::unique_lock<std::mutex> lock(
const_cast<std::mutex &
>(logmtx_));
125template <
typename Data>
128 std::unique_lock<std::mutex> lock(logmtx_);
130 log_.push_back({std::chrono::steady_clock::now(),
131 std::this_thread::get_id(),
136template <
typename Data>
139 std::unique_lock<std::mutex> lock(logmtx_);
A circular buffer with fixed size, contiguous storage and generic elements.
Data data
User logged data.
std::chrono::time_point< std::chrono::steady_clock > moment
When.
std::thread::id author
Who.
FastLog(size_t capacity)
Create an empty log with the given capacity.
A thread-safe circular buffer in memory to store logs.
bool empty(void) const
Return true if the log is empty.
void extract(Datum &ld)
Extract the oldest datum or throw if none.
void add(const Data &data)
Add a log datum.
void clear(void)
Clear the log.
size_t size(void) const
Return the number of logged items.
Actual data stored in the log.