Files
ternfs-XTXMarkets/cpp/core/Loop.hpp
Francesco Mazzoli 53049d5779 Shard batch writes, use batch UDP syscalls
The idea is to drain the socket and do a single RocksDB WAL
write/fsync for all the write requests we have found.

The read requests are immediately executed. The reasoning here is
that currently write requests are _a lot_ slower than the read
requests because fsyncing takes ~500us on fsf1. In the future this
might change.

Since we're at it, we also use batch UDP syscalls in the CDC.

Fixes #119.
2023-12-07 14:29:07 +00:00

33 lines
644 B
C++

#pragma once
#include <pthread.h>
#include "Env.hpp"
#include "Exception.hpp"
struct Loop {
protected:
Env _env;
private:
std::string _name;
public:
Loop(Logger& logger, std::shared_ptr<XmonAgent>& xmon, const std::string& name) : _env(logger, xmon, name), _name(name) {
int ret = pthread_setname_np(pthread_self(), name.c_str());
if (ret != 0) {
throw EXPLICIT_SYSCALL_EXCEPTION(ret, "pthreat_setname_np %s", name);
}
}
const std::string& name() const {
return _name;
}
virtual void step() = 0;
[[noreturn]] void run() {
for (;;) { step(); }
}
};