Skip to content

Commit

Permalink
Refactored elapsed calc
Browse files Browse the repository at this point in the history
  • Loading branch information
dionjansen committed Jan 3, 2021
1 parent 26cd957 commit f4725f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/DotPulsar/Internal/UnackedMessageTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
public readonly struct AwaitingAck
{
public MessageId MessageId { get; }
public Stopwatch Stopwatch { get; }
public long Timestamp { get; }

public AwaitingAck(MessageId messageId)
{
MessageId = messageId;
Stopwatch = Stopwatch.StartNew();
Timestamp = Stopwatch.GetTimestamp();
}

public TimeSpan Elapsed => Stopwatch.Elapsed;
public TimeSpan Elapsed => TimeSpan.FromTicks(
(long) ((Stopwatch.GetTimestamp() - Timestamp) / (double)Stopwatch.Frequency * TimeSpan.TicksPerSecond));
}

public sealed class UnackedMessageTracker : IUnackedMessageTracker
Expand Down

0 comments on commit f4725f5

Please sign in to comment.