Simple-Log  alpha-v0.7
sl::log::TimedFlushPolicy Class Reference

A Flush-Policy which acts on a durations. More...

#include <FlushPolicies.hpp>

Public Types

using Duration_t = std::chrono::milliseconds
 
using Clock_t = std::chrono::steady_clock
 
using TimePoint_t = Clock_t::time_point
 

Public Member Functions

template<class TRep , class TPeriod >
 TimedFlushPolicy (std::chrono::duration< TRep, TPeriod > duration)
 Constructs the object with the specified duration threshold. More...
 
template<Record TRecord>
bool operator() (const TRecord &record, std::size_t messageByteSize) noexcept
 Invoke operator. More...
 
void flushed () noexcept
 Restarts the internal duration clock. More...
 

Detailed Description

A Flush-Policy which acts on a durations.

Instances of this class will return true if their given duration has been exceeded. This class uses durations based on milliseconds, thus any provided duration will be casted to that.

Member Typedef Documentation

◆ Clock_t

using sl::log::TimedFlushPolicy::Clock_t = std::chrono::steady_clock

◆ Duration_t

using sl::log::TimedFlushPolicy::Duration_t = std::chrono::milliseconds

◆ TimePoint_t

using sl::log::TimedFlushPolicy::TimePoint_t = Clock_t::time_point

Constructor & Destructor Documentation

◆ TimedFlushPolicy()

template<class TRep , class TPeriod >
sl::log::TimedFlushPolicy::TimedFlushPolicy ( std::chrono::duration< TRep, TPeriod >  duration)
inlineexplicit

Constructs the object with the specified duration threshold.

Template Parameters
TRepAn arithmetic type representing the number of ticks
TPeriodPeriod type
Parameters
durationThe duration threshold.

Any provided duration will be casted to milliseconds, thus finer thresholds will be lost.

Member Function Documentation

◆ flushed()

void sl::log::TimedFlushPolicy::flushed ( )
inlinenoexcept

Restarts the internal duration clock.

◆ operator()()

template<Record TRecord>
bool sl::log::TimedFlushPolicy::operator() ( const TRecord &  record,
std::size_t  messageByteSize 
)
inlinenoexcept

Invoke operator.

Template Parameters
TRecordUsed Record type
Parameters
recordThe current handled Record object
messageByteSizeThe size of the current handled message in bytes
Returns
Returns true if the duration has been exceeded.

The documentation for this class was generated from the following file: