Chromium Code Reviews| Index: blimp/net/helium/vector_clock.h |
| diff --git a/blimp/net/helium/vector_clock.h b/blimp/net/helium/vector_clock.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..56c90cbe088313ba6c6e879d5e433d21c05f7700 |
| --- /dev/null |
| +++ b/blimp/net/helium/vector_clock.h |
| @@ -0,0 +1,34 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ |
| +#define BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ |
| + |
| +#include <cinttypes> |
|
Kevin M
2016/09/27 17:31:10
<stdint.h> is used more frequently
scf
2016/09/27 18:29:59
Done.
|
| + |
| +#include "blimp/net/blimp_net_export.h" |
| + |
| +namespace blimp { |
| + |
| +class BLIMP_NET_EXPORT VectorClock { |
|
Kevin M
2016/09/27 17:31:10
Add comment to class describing what vector clocks
scf
2016/09/27 18:29:59
Done.
|
| + public: |
| + VectorClock(int32_t local_revision, int32_t remote_revision); |
|
Kevin M
2016/09/27 17:31:10
Does it make sense to have a default -public const
scf
2016/09/27 18:29:59
Agree, default public makes sense.
|
| + |
| + enum class Comparison { LessThan, EqualTo, GreaterThan, Conflicts }; |
|
Kevin M
2016/09/27 17:31:10
Enums go at the top of public:
Kevin M
2016/09/27 17:31:10
Potentially misguided language nit:
What about "C
scf
2016/09/27 18:29:59
Done.
scf
2016/09/27 18:29:59
Done.
|
| + |
| + Comparison CompareTo(const VectorClock& other) const; |
|
Kevin M
2016/09/27 17:31:10
Add comments for all public members except maybe t
scf
2016/09/27 18:29:59
Done.
|
| + VectorClock MergeWith(const VectorClock& other); |
| + void IncrementLocal(); |
| + |
| + int32_t local_revision() { return local_revision_; } |
| + int32_t remote_revision() { return remote_revision_; } |
| + |
| + private: |
| + int32_t local_revision_ = 0; |
| + int32_t remote_revision_ = 0; |
| +}; |
| + |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ |