mirror of
https://github.com/XTXMarkets/ternfs.git
synced 2026-01-12 05:49:59 -06:00
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.
33 lines
644 B
C++
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(); }
|
|
}
|
|
};
|