mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
48 lines
1,023 B
C++
48 lines
1,023 B
C++
// Copyright 2022, Roman Gershman. All rights reserved.
|
|
// See LICENSE for licensing terms.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include "io/file.h"
|
|
#include "server/table.h"
|
|
#include "util/fibers/simple_channel.h"
|
|
|
|
namespace dfly {
|
|
|
|
class RdbSerializer;
|
|
|
|
class RdbSnapshot {
|
|
public:
|
|
using StringChannel =
|
|
::util::fibers_ext::SimpleChannel<std::string, base::mpmc_bounded_queue<std::string>>;
|
|
|
|
RdbSnapshot(PrimeTable* prime, ExpireTable* et, StringChannel* dest);
|
|
~RdbSnapshot();
|
|
|
|
void Start(uint64_t version);
|
|
void Join();
|
|
|
|
uint64_t snapshot_version() const {
|
|
return snapshot_version_;
|
|
}
|
|
|
|
private:
|
|
void FiberFunc();
|
|
void FlushSfile();
|
|
void PhysicalCb(MainIterator it);
|
|
|
|
::boost::fibers::fiber fb_;
|
|
|
|
std::unique_ptr<io::StringFile> sfile_;
|
|
std::unique_ptr<RdbSerializer> rdb_serializer_;
|
|
|
|
// version upper bound for entries that should be saved (not included).
|
|
uint64_t snapshot_version_ = 0;
|
|
PrimeTable* prime_table_;
|
|
StringChannel* dest_;
|
|
|
|
uint64_t processed_ = 0;
|
|
};
|
|
|
|
} // namespace dfly
|