Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ | 5 #ifndef BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ |
| 6 #define BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ | 6 #define BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "blimp/common/proto/helium.pb.h" | |
| 11 | |
| 10 namespace blimp { | 12 namespace blimp { |
| 11 | 13 |
| 12 // From wikipedia: | 14 // From wikipedia: |
| 13 // A vector clock is an algorithm for generating a partial ordering of events | 15 // A vector clock is an algorithm for generating a partial ordering of events |
| 14 // in a distributed system and detecting causality violations. This is used | 16 // in a distributed system and detecting causality violations. This is used |
| 15 // in Blimp to allow client and server modify a local copy of an object and | 17 // in Blimp to allow client and server modify a local copy of an object and |
| 16 // later be able to detect ordering or conflicts if any. | 18 // later be able to detect ordering or conflicts if any. |
| 17 // | 19 // |
| 18 // For more info see: | 20 // For more info see: |
| 19 // https://en.wikipedia.org/wiki/Vector_clock | 21 // https://en.wikipedia.org/wiki/Vector_clock |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 49 void set_local_revision(Revision local_revision) { | 51 void set_local_revision(Revision local_revision) { |
| 50 local_revision_ = local_revision; | 52 local_revision_ = local_revision; |
| 51 } | 53 } |
| 52 | 54 |
| 53 Revision remote_revision() const { return remote_revision_; } | 55 Revision remote_revision() const { return remote_revision_; } |
| 54 | 56 |
| 55 void set_remote_revision(Revision remote_revision) { | 57 void set_remote_revision(Revision remote_revision) { |
| 56 remote_revision_ = remote_revision; | 58 remote_revision_ = remote_revision; |
| 57 } | 59 } |
| 58 | 60 |
| 61 // Create the ProtoBuf object corresponding to this object | |
|
Kevin M
2016/10/03 21:44:26
"proto message"; trailing period; const
scf
2016/10/03 22:20:18
Done.
| |
| 62 helium::VectorClockMessage ToProto(); | |
| 63 | |
| 64 // Inverts the local and remote components respectively | |
|
Kevin M
2016/10/03 21:44:26
Trailing period.
scf
2016/10/03 22:20:18
Done.
| |
| 65 // Used when we send VectorClock across the wire. The local becomes | |
| 66 // remote and vice versa. | |
| 67 VectorClock Invert(); | |
|
Kevin M
2016/10/03 21:44:26
const
scf
2016/10/03 22:20:18
Done.
| |
| 68 | |
| 59 private: | 69 private: |
| 60 Revision local_revision_ = 0; | 70 Revision local_revision_ = 0; |
| 61 Revision remote_revision_ = 0; | 71 Revision remote_revision_ = 0; |
| 62 }; | 72 }; |
| 63 | 73 |
| 64 } // namespace blimp | 74 } // namespace blimp |
| 65 | 75 |
| 66 #endif // BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ | 76 #endif // BLIMP_NET_HELIUM_VECTOR_CLOCK_H_ |
| OLD | NEW |