-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocksaver.h
49 lines (36 loc) · 965 Bytes
/
blocksaver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef _BLOCKSAVER_H_
#define _BLOCKSAVER_H_
#include "dataoperation_file.h"
#include "dataoperation_mysql.h"
#include "datamanager.h"
#include <thread>
#include <chrono>
#include <iostream>
#include <vector>
#include <libconfig.h++>
using namespace std;
class SyncWorker
{
public:
void DoDiffs();
std::unique_ptr<DataManager> dataManager;
std::chrono::duration<double> diffPeriod;
DataManager::AddAndRemoveDataListPair diffResult;
std::chrono::time_point<std::chrono::system_clock> lastEndDiff;
};
class SyncManager
{
public:
SyncManager();
void Run();
void AddWorker(DataManager* dataManager, std::chrono::duration<double> diffPeriod);
private:
void DoInit();
void DoDiffs();
void DoSync();
void Sync(DataManager::AddAndRemoveDataListPair& diffResult, DataManager& sourceManager, DataManager& destManager);
private:
std::vector<std::unique_ptr<SyncWorker>> m_Workers;
bool m_KeepRun;
};
#endif