You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spdlog/include/c11log/details/flush_helper.h

33 lines
570 B
C

12 years ago
#pragma once
// Flush to file every X writes..
namespace c11log
{
namespace details
{
class file_flush_helper
{
12 years ago
public:
explicit file_flush_helper(const std::size_t flush_every):
_flush_every(flush_every),
_write_counter(0) {};
12 years ago
void write(std::ofstream& ofs, const bufpair_t& msg)
{
12 years ago
ofs.write(msg.first, msg.second);
if(++_write_counter == _flush_every)
{
12 years ago
ofs.flush();
_write_counter = 0;
12 years ago
}
}
private:
const std::size_t _flush_every;
std::size_t _write_counter;
12 years ago
};
}
}