-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathvclock.h
53 lines (44 loc) · 1.48 KB
/
vclock.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
50
51
52
53
/*
* ===============================================================
* Description: Vector of event counters, one for each vector
* timestamper. Basically a wrapper class around
* a vector of ints.
*
* Created: 01/15/2013 06:23:23 PM
*
* Author: Ayush Dubey, [email protected]
*
* Copyright (C) 2013, Cornell University, see the LICENSE file
* for licensing agreement
* ===============================================================
*/
#ifndef weaver_common_vclock_h_
#define weaver_common_vclock_h_
#include <memory>
#include <vector>
#include <algorithm>
#include <assert.h>
#include "common/utils.h"
namespace vc
{
typedef std::vector<uint64_t> vclock_t;
typedef std::vector<uint64_t> qtimestamp_t;
class vclock
{
public:
uint64_t vt_id;
vclock_t clock;
vclock() : vt_id(UINT64_MAX) { }
vclock(uint64_t vt_id, uint64_t clk_init);
vclock(uint64_t vt_id, vclock_t &vclk);
void new_epoch(uint64_t epoch_num);
uint64_t get_clock() const { return clock[vt_id+1]; }
uint64_t get_epoch() const { return clock[0]; }
void increment_clock() { clock[vt_id+1]++; }
void update_clock(vc::vclock &other);
bool operator==(const vclock &rhs) const;
bool operator!=(const vclock &rhs) const;
};
using vclock_ptr_t = std::shared_ptr<vclock>;
}
#endif