Class ILLIXR::record_coalescer
ClassList > ILLIXR > record_coalescer
Coalesces logs of the same type to be written back as a single-transaction. More...
#include <record_logger.hpp>
Public Functions
Type | Name |
---|---|
void | flush () Flush buffer of logs to the underlying logger. |
void | log (const record & r) Appends a log to the buffer, which will eventually be written. |
void | maybe_flush () Use internal decision process, and possibly trigger flush. |
operator bool () const |
|
record_coalescer (std::shared_ptr< record_logger > logger_) |
|
~record_coalescer () |
Detailed Description
Records should all be of the same type. TODO: remove this constraint. Use log<record_type>(Args... args)
and std::forward
.
In some backend-implementations, logging many logs of the same type is more efficient than logging them individually; However, the client often wants to produce one log-record at a time. This class resolves this mismatch by buffering logs from the client. Every time a new log is added, an internal decision process determines whether or not to flush the buffer, or keep accumulating and wait until later.
Currently this internal decision process is "is the oldest log in the buffer more than 1 second old?". I chose this because this frequency should have very little overhead, even if every component is also coalescing at 1 per second.
At destructor time, any remaining logs are flushed.
Use like:
log_coalescer(logger);
lc.log(make_my_record(id_, it, skip_it, ...));
Public Functions Documentation
function flush
Flush buffer of logs to the underlying logger.
inline void ILLIXR::record_coalescer::flush ()
function log
Appends a log to the buffer, which will eventually be written.
inline void ILLIXR::record_coalescer::log (
const record & r
)
function maybe_flush
Use internal decision process, and possibly trigger flush.
inline void ILLIXR::record_coalescer::maybe_flush ()
function operator bool
inline explicit ILLIXR::record_coalescer::operator bool () const
function record_coalescer
inline explicit ILLIXR::record_coalescer::record_coalescer (
std::shared_ptr< record_logger > logger_
)
function ~record_coalescer
inline ILLIXR::record_coalescer::~record_coalescer ()
The documentation for this class was generated from the following file /home/friedel/devel/ILLIXR/include/illixr/record_logger.hpp