Skip to content

Instantly share code, notes, and snippets.

View ashalkhakov's full-sized avatar

Artyom Shalkhakov ashalkhakov

View GitHub Profile
@ashalkhakov
ashalkhakov / HybridLogicalClock.cs
Created December 26, 2023 15:17
Hybrid Logical Clock in C#
namespace HLC;
/// <summary>
/// The Hybrid Logical Clock. Contains both Physical Time and Logical Clock inside.
/// Grows monotonically, can be used to obtain unique timestamps even if called more often than
/// allowed by the physical clock precision.
///
/// <see cref="https://cse.buffalo.edu/tech-reports/2014-04.pdf"/>
/// </summary>
/// <remarks>Single-threaded use only!</remarks>