Change time to duration.
Reviewers: florijan Reviewed By: florijan Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D403
This commit is contained in:
parent
5406882bde
commit
db5f4469fe
@ -10,8 +10,8 @@
|
||||
|
||||
const int DEFAULT_CLEANING_CYCLE_SEC = 30; // 30 seconds
|
||||
const std::string DEFAULT_SNAPSHOT_FOLDER = "snapshots";
|
||||
const int DEFAULT_MAX_RETAINED_SNAPSHOTS = -1; // unlimited number of snapshots
|
||||
const int DEFAULT_SNAPSHOT_CYCLE_SEC = -1; // off
|
||||
const int DEFAULT_MAX_RETAINED_SNAPSHOTS = -1; // unlimited number of snapshots
|
||||
const int DEFAULT_SNAPSHOT_CYCLE_SEC = -1; // off
|
||||
|
||||
GraphDb::GraphDb(const std::string &name, bool import_snapshot)
|
||||
: name_(name),
|
||||
@ -71,7 +71,7 @@ GraphDb::GraphDb(const std::string &name, bool import_snapshot)
|
||||
max_retained_snapshots_]() -> void {
|
||||
GraphDbAccessor db_accessor(*this);
|
||||
snapshooter_.MakeSnapshot(db_accessor, fs::path(snapshot_folder_) / name_,
|
||||
max_retained_snapshots_);
|
||||
max_retained_snapshots_);
|
||||
};
|
||||
snapshot_creator_.Run(std::chrono::seconds(snapshot_cycle_sec_),
|
||||
create_snapshot);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "database/graph_db_datatypes.hpp"
|
||||
#include "database/indexes/key_index.hpp"
|
||||
#include "database/indexes/label_property_index.hpp"
|
||||
#include "durability/snapshooter.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/deferred_deleter.hpp"
|
||||
#include "storage/edge.hpp"
|
||||
@ -18,7 +19,6 @@
|
||||
#include "storage/vertex.hpp"
|
||||
#include "transactions/engine.hpp"
|
||||
#include "utils/scheduler.hpp"
|
||||
#include "durability/snapshooter.hpp"
|
||||
|
||||
// TODO: Maybe split this in another layer between Db and Dbms. Where the new
|
||||
// layer would hold SnapshotEngine and his kind of concept objects. Some
|
||||
@ -86,7 +86,7 @@ class GraphDb {
|
||||
ConcurrentSet<std::string> labels_;
|
||||
ConcurrentSet<std::string> edge_types_;
|
||||
ConcurrentSet<std::string> properties_;
|
||||
|
||||
|
||||
// indexes
|
||||
KeyIndex<GraphDbTypes::Label, Vertex> labels_index_;
|
||||
KeyIndex<GraphDbTypes::EdgeType, Edge> edge_types_index_;
|
||||
|
@ -16,12 +16,16 @@ class Scheduler {
|
||||
public:
|
||||
Scheduler() {}
|
||||
/**
|
||||
* @param pause - Time between executing function. If function is still
|
||||
* running when it should be ran again, it will not be ran and next start time
|
||||
* will be increased to current time plus pause.
|
||||
* @param f - Function which will be executed.
|
||||
* @param pause - Duration between two function executions. If function is
|
||||
* still running when it should be ran again, it will not be ran and next
|
||||
* start time will be increased to current time plus pause.
|
||||
* @param f - Function
|
||||
* @Tparam TRep underlying arithmetic type in duration
|
||||
* @Tparam TPeriod duration in seconds between two ticks
|
||||
*/
|
||||
void Run(const std::chrono::seconds &pause, const std::function<void()> &f) {
|
||||
template <typename TRep, typename TPeriod>
|
||||
void Run(const std::chrono::duration<TRep, TPeriod> &pause,
|
||||
const std::function<void()> &f) {
|
||||
debug_assert(is_working_ == false, "Thread already running.");
|
||||
is_working_ = true;
|
||||
thread_ = std::thread([this, pause, f]() {
|
||||
|
Loading…
Reference in New Issue
Block a user