Skip to content

Commit

Permalink
Improved handling coordinated omission
Browse files Browse the repository at this point in the history
  • Loading branch information
pveentjer committed Jan 27, 2025
1 parent 456fc19 commit 222569a
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,27 @@ private void runTest(final int durationSeconds, final int messageRate)
}

int workCount = 0;

final long now = clock.nanoTime();

if (moreToGenerate && now - nextMessageAt >= 0)
{
generationTimestamps[freePosition++] = now;

workCount += trySend();
int trySend = trySend(nextMessageAt);

generatedMessages++;
nextMessageAt += periodNs;
if (trySend == 0)
{
freePosition--;
}
else
{
workCount += trySend;
generatedMessages++;
nextMessageAt += periodNs;
}

// todo: not sure what to do with this section.
if (now - nextMessageAt >= 0)
{
fallingBehindCount++;
Expand All @@ -256,8 +266,6 @@ private void runTest(final int durationSeconds, final int messageRate)

workCount += transceiver.receive();

workCount += trySend();

if (now - deadline >= 0)
{
throw new RuntimeException("Timed out");
Expand Down Expand Up @@ -285,15 +293,14 @@ private void runTest(final int durationSeconds, final int messageRate)
out.println("Stats: fallingBehindCount=" + fallingBehindCount);
}

private int trySend()
private int trySend(final long timestamp)
{
if (!synced || sendPosition >= freePosition)
{
return 0;
}

final int sequence = sendPosition;
final long timestamp = generationTimestamps[sendPosition];

if (transceiver.trySendEcho(sequence, timestamp))
{
Expand Down

0 comments on commit 222569a

Please sign in to comment.