Skip to content

Commit 39bb37d

Browse files
authored
Fixes for RedoContinuousViaFutures snippets and Java linting fixes for indentation (#87)
1 parent 1661b43 commit 39bb37d

14 files changed

+2680
-2683
lines changed

csharp/snippets/redo/RedoContinuousViaFutures/Program.cs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,10 @@ TaskScheduler taskScheduler
7373
{
7474
// loop through the example records and queue them up so long
7575
// as we have more records and backlog is not too large
76-
while (pendingFutures.Count < MaximumBacklog)
76+
for (string redo = engine.GetRedoRecord();
77+
redo != null;
78+
redo = engine.GetRedoRecord())
7779
{
78-
79-
// get the next redo record
80-
string redo = engine.GetRedoRecord();
81-
82-
// check if no redo records are available
83-
if (redo == null) break;
84-
8580
Task task = factory.StartNew(() =>
8681
{
8782
engine.ProcessRedoRecord(redo, SzNoFlags);
@@ -92,28 +87,32 @@ TaskScheduler taskScheduler
9287

9388
// add the future to the pending future list
9489
pendingFutures.Add((task, redo));
95-
}
96-
97-
do
98-
{
99-
// handle any pending futures WITHOUT blocking to reduce the backlog
100-
HandlePendingFutures(pendingFutures, false);
10190

102-
// if we still have exceeded the backlog size then pause
103-
// briefly before trying again
104-
if (pendingFutures.Count >= MaximumBacklog)
91+
// handle the pending futures as log as maximum backlog exceeded
92+
for (int loop = 0;
93+
pendingFutures.Count >= MaximumBacklog;
94+
loop++)
10595
{
106-
try
96+
// check if this is NOT our first iteration through the loop
97+
if (loop > 0)
10798
{
108-
Thread.Sleep(HandlePauseTimeout);
109-
110-
}
111-
catch (ThreadInterruptedException)
112-
{
113-
// do nothing
99+
// if we still have exceeded the backlog size after the first
100+
// loop iteration then pause briefly before trying again
101+
try
102+
{
103+
Thread.Sleep(HandlePauseTimeout);
104+
105+
}
106+
catch (ThreadInterruptedException)
107+
{
108+
// do nothing
109+
}
114110
}
111+
112+
// handle any pending futures WITHOUT blocking to reduce the backlog
113+
HandlePendingFutures(pendingFutures, false);
115114
}
116-
} while (pendingFutures.Count >= MaximumBacklog);
115+
}
117116

118117
// check if there are no redo records right now
119118
// NOTE: we do NOT want to call countRedoRecords() in a loop that

0 commit comments

Comments
 (0)