memgraph/src/database/graph_db.cpp
Dominik Gleich fd2780155a Refactor GC to use scheduler.
Reviewers: buda, matej.gradicek

Reviewed By: matej.gradicek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D247
2017-04-10 15:57:45 +02:00

31 lines
1.1 KiB
C++

#include <functional>
#include "config/config.hpp"
#include "database/creation_exception.hpp"
#include "database/graph_db.hpp"
#include "logging/logger.hpp"
#include "storage/edge.hpp"
#include "storage/garbage_collector.hpp"
//#include "snapshot/snapshoter.hpp"
const int DEFAULT_CLEANING_CYCLE_SEC = 30; // 30 seconds
GraphDb::GraphDb(const std::string &name, bool import_snapshot)
: name_(name),
gc_vertices_(&vertices_, &tx_engine),
gc_edges_(&edges_, &tx_engine) {
const std::string time_str = CONFIG(config::CLEANING_CYCLE_SEC);
int pause = DEFAULT_CLEANING_CYCLE_SEC;
if (!time_str.empty()) pause = CONFIG_INTEGER(config::CLEANING_CYCLE_SEC);
// Pause of -1 means we shouldn't run the GC.
if (pause != -1) {
gc_vertices_scheduler_.Run(
std::chrono::seconds(pause),
std::bind(&GarbageCollector<Vertex>::Run, gc_vertices_));
gc_edges_scheduler_.Run(std::chrono::seconds(pause),
std::bind(&GarbageCollector<Edge>::Run, gc_edges_));
}
// if (import_snapshot)
// snap_engine.import();
}