Browse Source

The log side is complete, now I need to do the sink side

main
Ludovic 'Archivist' Lagouardette 1 year ago
parent
commit
bc12d2284f
11 changed files with 528 additions and 140 deletions
  1. +2
    -2
      LibSnugLog/CMakeLists.txt
  2. +115
    -32
      LibSnugLog/include/disruptor.h
  3. +20
    -0
      LibSnugLog/include/registry.h
  4. +7
    -0
      LibSnugLog/public_include/sl/logger.h
  5. +73
    -73
      LibSnugLog/public_include/sl/register.h
  6. +6
    -5
      LibSnugLog/public_include/sl/strategies.h
  7. +2
    -2
      LibSnugLog/public_include/sl/transaction.h
  8. +16
    -0
      LibSnugLog/source/logger.cpp
  9. +282
    -21
      LibSnugLog/source/registry.cpp
  10. +1
    -1
      Tests/CMakeLists.txt
  11. +4
    -4
      Tests/disruptor.cpp

+ 2
- 2
LibSnugLog/CMakeLists.txt View File

@ -3,6 +3,6 @@ include_directories(./public_include)
include_directories(./include)
add_library(LibSnugLog
add_library(SnugLog
include/disruptor.h
source/disruptor.cpp include/sink.h include/registry.h include/source.h public_include/sl/strategies.h public_include/sl/register.h public_include/sl/transaction.h source/registry.cpp)
source/disruptor.cpp include/sink.h include/registry.h include/source.h public_include/sl/strategies.h public_include/sl/register.h public_include/sl/transaction.h source/registry.cpp public_include/sl/logger.h source/logger.cpp)

+ 115
- 32
LibSnugLog/include/disruptor.h View File

@ -6,6 +6,7 @@
#include <cassert>
#include <optional>
#include <iostream>
#include <any>
#include "sl/strategies.h"
@ -19,13 +20,14 @@ static constexpr size_t line_length = 64;
template<typename T>
struct alignas(max_interference_size) padded_atomic final {
std::atomic<T> value;
std::atomic<T> value;
};
using offset_t = size_t;
extern const size_t page_size;
struct force_contiguous_mode {};
struct force_contiguous_mode_t {};
constexpr force_contiguous_mode_t force_contiguous_mode;
struct token_t {offset_t start; offset_t end;};
struct disruptor_exception : public std::runtime_error {
@ -41,37 +43,73 @@ class disruptor
{
char* buffer;
size_t buffer_size;
std::atomic<offset_t>& read_trailer;
std::atomic<offset_t>& read_lead;
std::atomic<offset_t>* read_trailer;
std::atomic<offset_t>* read_lead;
std::atomic<offset_t>* write_trailer;
std::atomic<offset_t>* write_lead;
std::atomic<offset_t>& write_trailer;
std::atomic<offset_t>& write_lead;
offset_t& max_offset;
offset_t* max_offset;
char* data_buffer;
std::any buffer_life_extender;
std::any strategy_life_extender;
public:
/**
* Constructs a disruptor from the provided strategy, initialization_and_checks() is responsible for the initialization
* @param strategy The provided strategy. The provided strategy is preserved, intact if properly movable and if moving is "pointer stable". The obtained buffer is also preserved under the same supposition.
* @param _buffer_size The total size of the buffer to allocate, keep in mind this includes not only the
*/
template<BufferStrategy buffer_strategy>
disruptor(buffer_strategy strategy, std::string_view _buffer_filename, const size_t _buffer_size)
: read_trailer{}
, read_lead{}
, write_trailer{}
, write_lead{}
{
auto tmp = strategy.build_buffer(_buffer_filename, _buffer_size);
buffer = tmp.data();
buffer_size = tmp.size();
read_trailer = reinterpret_cast<std::atomic<offset_t>*>(buffer+max_interference_size*0);
read_lead = reinterpret_cast<std::atomic<offset_t>*>(buffer+max_interference_size*1);
write_trailer = reinterpret_cast<std::atomic<offset_t>*>(buffer+max_interference_size*2);
write_lead = reinterpret_cast<std::atomic<offset_t>*>(buffer+max_interference_size*3);
max_offset = reinterpret_cast<offset_t*> (buffer+max_interference_size*4);
buffer_life_extender = std::move(tmp);
strategy_life_extender = std::move(strategy);
initialization_and_checks();
}
/**
* Constructs a disruptor from the provided memory span, initialization_and_checks() is responsible for the initialization
* @ref initialization_and_checks()
* @param _buffer
* @param _buffer_size
*/
disruptor(char* _buffer, const size_t _buffer_size)
: buffer(_buffer)
, buffer_size(_buffer_size)
, read_trailer (*reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*0))
, read_lead (*reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*1))
, write_trailer(*reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*2))
, write_lead (*reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*3))
, max_offset (*reinterpret_cast<offset_t*> (_buffer+max_interference_size*4))
, read_trailer (reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*0))
, read_lead (reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*1))
, write_trailer(reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*2))
, write_lead (reinterpret_cast<std::atomic<offset_t>*>(_buffer+max_interference_size*3))
, max_offset (reinterpret_cast<offset_t*> (_buffer+max_interference_size*4))
{
initialization_and_checks();
}
void initialization_and_checks() {
if(buffer_size <= page_size) throw disruptor_exception("buffer size too small to build a disruptor");
data_buffer = buffer+max_interference_size*5;
if(data_buffer <= buffer+page_size) {
data_buffer = buffer+page_size;
max_offset = buffer_size - page_size;
o">*max_offset = buffer_size - page_size;
} else if(data_buffer > buffer+page_size) {
size_t ctr = 0;
do {
ctr++;
} while(data_buffer > buffer+page_size*ctr);
data_buffer = buffer+page_size*ctr;
max_offset = buffer_size - page_size*ctr;
o">*max_offset = buffer_size - page_size*ctr;
}
}
@ -81,9 +119,9 @@ public:
std::atomic<offset_t>& fence,
offset_t amount
) {
offset_t old_offset = lead.load(std::memory_order_relaxed);
offset_t old_offset = lead.load(std::memory_order_seq_cst);
offset_t new_offset = old_offset + amount;
offset_t fence_v = fence.load(std::memory_order_relaxed);
offset_t fence_v = fence.load(std::memory_order_seq_cst);
// Check if we jumped the fence
if(fence_v <= new_offset && fence_v > old_offset) {
@ -91,11 +129,11 @@ public:
}
// Check if we jumped the fence while overflowing
if(new_offset >= max_offset) {
if(new_offset >= o">*max_offset) {
if constexpr(must_be_contiguous) {
new_offset = amount;
} else {
new_offset %= max_offset;
new_offset %= o">*max_offset;
}
if(fence_v <= new_offset) {
goto handle_fence;
@ -107,14 +145,14 @@ public:
if constexpr (OverflowStrategyType::on_overflow == overflow_response_t::must_wait) {
return std::nullopt;
} else if constexpr (OverflowStrategyType::on_overflow == overflow_response_t::must_overflow) {
if(!fence.compare_exchange_weak(fence_v, new_offset, std::memory_order_release, std::memory_order_relaxed)) {
if(!fence.compare_exchange_weak(fence_v, new_offset, std::memory_order_seq_cst)) {
return std::nullopt;
} else {
offset_t v;
do {
v = read_leadp">.load(std::memory_order_acquire);
v = read_leado">->load(std::memory_order_seq_cst);
if(v >= new_offset) break;
} while(read_leadp">.compare_exchange_weak(v, new_offset, std::memory_order_release, std::memory_order_relaxed));
} while(read_leado">->compare_exchange_weak(v, new_offset, std::memory_order_seq_cst));
}
} else {
static_assert(
@ -124,7 +162,7 @@ public:
}
handle_fence_end:
if(!lead.compare_exchange_weak(old_offset, new_offset, std::memory_order_acquire, std::memory_order_relaxed)) {
if(!lead.compare_exchange_weak(old_offset, new_offset, std::memory_order_seq_cst, std::memory_order_seq_cst)) {
return std::nullopt;
}
@ -135,18 +173,18 @@ public:
std::optional<token_t> tok;
OverflowStrategyType waiter;
while(true) {
tok = try_advance(write_lead, read_trailer, sz);
tok = try_advance(o">*write_lead, *read_trailer, sz);
if(tok) break;
waiter.wait();
}
// std::cout << tok.value().start << " rw " << tok.value().end << std::endl;
return tok.value();
}
token_t reserve_write(size_t sz, force_contiguous_mode) {
token_t reserve_write(size_t sz, force_contiguous_mode_t) {
std::optional<token_t> tok;
OverflowStrategyType waiter;
while(true) {
tok = try_advance<true>(write_lead, read_trailer, sz);
tok = try_advance<true>(o">*write_lead, *read_trailer, sz);
if(tok) break;
waiter.wait();
}
@ -158,18 +196,18 @@ public:
void conclude_write(token_t tok) noexcept(std::is_nothrow_invocable_v<decltype(tmp_fn), OverflowStrategyType>) {
OverflowStrategyType waiter;
while(!write_trailerp">.compare_exchange_weak(tok.start, tok.end, std::memory_order_release, std::memory_order_relaxed)) {
while(!write_trailero">->compare_exchange_weak(tok.start, tok.end, std::memory_order_seq_cst, std::memory_order_seq_cst)) {
waiter.wait();
}
}
token_t reserve_read() {
offset_t old_offset = read_leadp">.load(std::memory_order_relaxed);
offset_t new_offset = write_trailerp">.load(std::memory_order_relaxed);
offset_t old_offset = read_leado">->load(std::memory_order_seq_cst);
offset_t new_offset = write_trailero">->load(std::memory_order_seq_cst);
if(old_offset > new_offset) new_offset = 0;
OverflowStrategyType waiter;
while(!read_leadp">.compare_exchange_weak(old_offset, new_offset, std::memory_order_acquire, std::memory_order_relaxed)) {
while(!read_leado">->compare_exchange_weak(old_offset, new_offset, std::memory_order_seq_cst, std::memory_order_seq_cst)) {
waiter.wait();
}
// std::cout << old_offset << " rr " << new_offset << std::endl;
@ -177,7 +215,7 @@ public:
}
void conclude_read(token_t tok) noexcept(std::is_nothrow_invocable_v<decltype(tmp_fn), OverflowStrategyType>) {
OverflowStrategyType waiter;
while(!read_trailerp">.compare_exchange_weak(tok.start, tok.end, std::memory_order_release, std::memory_order_relaxed)) {
while(!read_trailero">->compare_exchange_weak(tok.start, tok.end, std::memory_order_seq_cst, std::memory_order_seq_cst)) {
waiter.wait();
}
// std::cout << tok.start << " cr " << tok.end << std::endl;
@ -187,7 +225,52 @@ public:
return data_buffer[offset];
}
char* data() {
return data_buffer;
}
[[nodiscard]] offset_t size() const {
return max_offset;
return o">*max_offset;
}
};
class write_span {
offset_t start, end;
size_t target_sz;
char* target_buffer;
public:
template<typename of_strat>
write_span(token_t tok, disruptor<of_strat>& _target)
: start(tok.start)
, end(tok.end)
, target_sz(_target.size())
, target_buffer(_target.data())
{}
private:
write_span(const write_span& src, size_t ltrim)
: start((src.start + ltrim) % src.target_sz)
, end(src.end)
, target_sz(src.target_sz)
, target_buffer(src.target_buffer)
{}
public:
char& front() {
return target_buffer[start];
}
[[nodiscard]] size_t size() const {
return start <= end ? end - start : end + target_sz - start;
}
write_span subspan(size_t ltrim) {
if(ltrim > size()) throw disruptor_exception("write_span overflow, ltrim greater than available span");
return write_span(*this, ltrim);
}
[[nodiscard]] bool empty() const {
return end==start;
}
};

+ 20
- 0
LibSnugLog/include/registry.h View File

@ -1,3 +1,23 @@
#pragma once
#include <unordered_map>
#include <string>
#include <functional>
#include <any>
#include "disruptor.h"
struct registry_slab {
int id;
std::string name;
std::function<token_t(size_t)> reserve_write;
std::function<token_t(size_t)> reserve_write_c_align;
std::function<void(token_t)> conclude_write;
std::function<write_span(token_t)> get_buffer;
std::any disruptor;
};
/**
* @internal used because we need the pointer stability
* @see sl_transaction
*/
extern std::unordered_map<int, registry_slab> registry_map;

+ 7
- 0
LibSnugLog/public_include/sl/logger.h View File

@ -0,0 +1,7 @@
#pragma once
#include <string>
namespace sl {
void log(int log_id, std::string line);
}

+ 73
- 73
LibSnugLog/public_include/sl/register.h View File

@ -59,103 +59,103 @@ namespace sl {
}
template<BufferStrategy b_strategy_t, SinkStrategy s_strategy_t, OverflowStrategy over_strategy_t, OutputStrategy out_strategy_t >
void register_log(std::string_view buffer_filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory);
void register_log(kt">int log_id, std::string_view log_name, std::string_view buffer_filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(kt">int log_id, std::string_view, std::string_view, uint64_t, uint64_t, std::string_view);
#else
typedef struct sl_buffer_strategy sl_buffer_strategy;
typedef struct sl_sink_strategy sl_sink_strategy;

+ 6
- 5
LibSnugLog/public_include/sl/strategies.h View File

@ -86,8 +86,9 @@ concept BufferLike = requires (T buffer) {
* @brief This concept maps a buffer strategy.
*/
template<typename T>
concept BufferStrategy = requires (T strategy, size_t size) {
{strategy.build_buffer(size)} -> BufferLike;
concept BufferStrategy = requires (T strategy, std::string_view filename, size_t size) {
{strategy.build_buffer(filename, size)} -> BufferLike;
{strategy.build_buffer(filename, size)} -> std::same_as<typename T::buffer_type>;
};
/**
@ -141,7 +142,7 @@ struct mapped_buffer {
struct BufferStrategyInternal {
using buffer_type = std::vector<char>;
static_assert(BufferLike<buffer_type>);
buffer_type build_buffer(size_t);
buffer_type build_buffer(std::string_view, size_t);
};
/**
@ -150,7 +151,7 @@ struct BufferStrategyInternal {
struct BufferStrategyShared {
using buffer_type = mapped_buffer;
static_assert(BufferLike<buffer_type>);
buffer_type build_buffer(size_t);
buffer_type build_buffer(std::string_view, size_t);
};
/**
@ -159,7 +160,7 @@ struct BufferStrategyShared {
struct BufferStrategyExternal {
using buffer_type = mapped_buffer;
static_assert(BufferLike<buffer_type>);
buffer_type build_buffer(size_t);
buffer_type build_buffer(std::string_view, size_t);
};
/* * ... * */

+ 2
- 2
LibSnugLog/public_include/sl/transaction.h View File

@ -239,8 +239,8 @@ inline void sl_clear_transaction(sl_log_transaction* to_clear) {
to_clear->internals = nullptr;
#else
to_clear->begin = NULL;
to_clear->end = NULL;
to_clear->internals = NULL;
to_clear->end = NULL;
to_clear->internals = NULL;
#endif
#endif
}

+ 16
- 0
LibSnugLog/source/logger.cpp View File

@ -0,0 +1,16 @@
#include <span>
#include "sl/logger.h"
#include "registry.h"
namespace sl {
void log(int log_id, std::string line) {
auto& slab = registry_map.at(log_id);
auto token = slab.reserve_write(line.size());
auto span = slab.get_buffer(token);
for(auto elem : line) {
span.front() = elem;
span = span.subspan(1);
}
slab.conclude_write(token);
}
}

+ 282
- 21
LibSnugLog/source/registry.cpp View File

@ -8,6 +8,12 @@
#include <functional>
#include <any>
#if defined(__linux__) || defined(__linux)
#include <sys/mman.h>
#include <fcntl.h>
#include <memory>
#endif
/**
* @brief A fast semaphore exclusion handler WITHOUT deadlock detection or yielding
@ -67,10 +73,11 @@ using rw_lock_type = fast_semaphore;
class lock_handler_read {
rw_lock_type& ref;
public:
explicit lock_handler_read(rw_lock_type& _ref) : ref(_ref) {
while(ref.try_lock<1>());
}
~lock_handler_read() {
while(ref.try_unlock<1>() != rw_lock_type::tristate::success);
}
@ -78,10 +85,11 @@ class lock_handler_read {
class lock_handler_write {
rw_lock_type& ref;
public:
explicit lock_handler_write(rw_lock_type& _ref) : ref(_ref) {
while(ref.try_lock());
}
~lock_handler_write() {
while(ref.try_unlock() != rw_lock_type::tristate::success);
}
@ -89,32 +97,285 @@ class lock_handler_write {
static fast_semaphore<int32_t, 256, 256> registry_rw_lock;
std::unordered_map<int, registry_slab> registry_map;
struct registry_slab {
int id;
std::string name;
std::function<token_t(size_t)> reserve_write;
std::function<token_t(size_t)> reserve_write_c_align;
std::function<void(token_t)> conclude_write;
std::any disruptor;
};
template<BufferStrategy buff_strat, SinkStrategy sink_strat, OverflowStrategy of_strat, OutputStrategy out_strat>
void register_log_impl(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
if(buffer_size % page_size != 0) {
// TODO: more meaningful exception
throw disruptor_exception{"Size provided for the disruptor doesn't align with page size"};
}
lock_handler_write lock_me{registry_rw_lock};
if(registry_map.contains(log_id)) {
// TODO: more meaningful exception
throw disruptor_exception{"Log ID already exists"};
}
registry_map.insert(std::pair<int, registry_slab>{log_id, {}});
auto& slab = registry_map[log_id];
slab.id = log_id;
slab.name = log_name;
auto* transient_reference = new disruptor<of_strat>(buff_strat{}, filename, buffer_size);
slab.disruptor = transient_reference;
slab.reserve_write = [ptr = transient_reference] (size_t sz) -> token_t{
return ptr->reserve_write(sz);
};
slab.reserve_write_c_align = [ptr = transient_reference] (size_t sz) -> token_t{
return ptr->reserve_write(sz, force_contiguous_mode);
};
slab.conclude_write = [ptr = transient_reference] (token_t tok) -> void {
ptr->conclude_write(tok);
};
slab.get_buffer = [self = slab, ptr = transient_reference] (token_t tok) -> write_span {
return write_span(tok, *ptr);
};
}
/**
* @internal used because we need the pointer stability
* @see sl_transaction
*/
static std::unordered_map<int, registry_slab> registry_map;
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyInternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyShared, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyDirect, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyFastest, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyMmaped, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyWait, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategyTimed>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySized>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
template<> void register_log<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(int log_id, std::string_view log_name, std::string_view filename, uint64_t buffer_size, uint64_t out_strategy_parameter, std::string_view output_directory) {
register_log_impl<BufferStrategyExternal, SinkStrategyExternal, OverflowStrategyContinue, OutputStrategySimple>(log_id, log_name, filename, buffer_size, out_strategy_parameter, output_directory);
}
BufferStrategyInternal::buffer_type BufferStrategyInternal::build_buffer(size_t) {
return {};
BufferStrategyInternal::buffer_type BufferStrategyInternal::build_buffer(std::string_view, size_t sz) {
return n">std::vector<char>(sz, 0);
}
BufferStrategyShared::buffer_type BufferStrategyShared::build_buffer(size_t) {
return {};
BufferStrategyShared::buffer_type BufferStrategyShared::build_buffer(std::string_view, size_t sz) {
#if defined(__linux__) || defined(__linux)
auto buff = mmap(nullptr, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
if(not buff) throw disruptor_exception{"Could not allocate memory for BufferStrategyShared"};
return {(char*)buff, sz};
#else
static_assert(false, "BufferStrategyShared strategy is unimplemented on your system");
#endif
}
BufferStrategyExternal::buffer_type BufferStrategyExternal::build_buffer(size_t) {
return {};
BufferStrategyExternal::buffer_type BufferStrategyExternal::build_buffer(std::string_view filename, size_t sz) {
#if defined(__linux__) || defined(__linux)
auto fd = open(std::string{filename}.c_str(), O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if(fd <= 0) throw disruptor_exception{"Could not open or create file for BufferStrategyExternal"};
if(ftruncate(fd, sz) != 0) throw disruptor_exception{"Could not ensure size for the file for BufferStrategyExternal"};
auto buff = mmap(nullptr, sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd, 0);
if(not buff) {
throw disruptor_exception{"Could not allocate memory for BufferStrategyExternal, mapping failed"};
}
return {(char*)buff, sz};
#else
static_assert(false, "BufferStrategyExternal strategy is unimplemented on your system");
#endif
}
void SinkStrategyDirect::write(int fd, std::string_view data) {

+ 1
- 1
Tests/CMakeLists.txt View File

@ -11,7 +11,7 @@ FetchContent_Declare(
FetchContent_MakeAvailable(Catch2)
add_executable(tests disruptor.cpp)
target_link_libraries(tests PRIVATE LibSnugLog)
target_link_libraries(tests PRIVATE SnugLog)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
include_directories(../LibSnugLog/public_include)

+ 4
- 4
Tests/disruptor.cpp View File

@ -135,19 +135,19 @@ TEST_CASE("Disruptor works sequentially") {
}
}
TEST_CASE("Fails if buffer too small") {
TEST_CASE("Fails if buffer too small - 1") {
REQUIRE_THROWS_AS(disruptor<strategy>(nullptr, page_size), disruptor_exception);
}
TEST_CASE("Fails if buffer size is 0") {
TEST_CASE("Fails if buffer size is 0 - 1") {
REQUIRE_THROWS_AS(disruptor<strategy>(nullptr, 0), disruptor_exception);
}
TEST_CASE("Fails if buffer too small") {
TEST_CASE("Fails if buffer too small - 2") {
REQUIRE_THROWS_AS(disruptor<strategy_that_overflows>(nullptr, page_size), disruptor_exception);
}
TEST_CASE("Fails if buffer size is 0") {
TEST_CASE("Fails if buffer size is 0 - 2") {
REQUIRE_THROWS_AS(disruptor<strategy_that_overflows>(nullptr, 0), disruptor_exception);
}

Loading…
Cancel
Save