summaryrefslogtreecommitdiff
path: root/include/erebos/sync.h
blob: 0b9ed9aa0eebc764552edf49fde43764e2ffd2e7 (plain)
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
#pragma once

#include <erebos/service.h>
#include <erebos/state.h>
#include <erebos/storage.h>

#include <optional>
#include <mutex>

namespace erebos {

class SyncService : public Service
{
public:
	SyncService();
	virtual ~SyncService();

	UUID uuid() const override;
	void handle(Context &) override;

	void serverStarted(const class Server &) override;

private:
	void peerWatcher(size_t, const class Peer *);
	void localStateWatcher(const Head<LocalState> &);

	const class Server * server;
	std::mutex headMutex;
	std::optional<WatchedHead<LocalState>> watchedHead;
};

}