Commit 7384ec02 authored by Nick Craver's avatar Nick Craver

Cleanup: CompletionManager

parent 402495c8
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
namespace StackExchange.Redis namespace StackExchange.Redis
{ {
sealed partial class CompletionManager internal sealed partial class CompletionManager
{ {
private static readonly WaitCallback processAsyncCompletionQueue = ProcessAsyncCompletionQueue, private static readonly WaitCallback processAsyncCompletionQueue = ProcessAsyncCompletionQueue,
anyOrderCompletionHandler = AnyOrderCompletionHandler; anyOrderCompletionHandler = AnyOrderCompletionHandler;
...@@ -16,13 +16,14 @@ sealed partial class CompletionManager ...@@ -16,13 +16,14 @@ sealed partial class CompletionManager
private readonly string name; private readonly string name;
int activeAsyncWorkerThread = 0; private int activeAsyncWorkerThread = 0;
long completedSync, completedAsync, failedAsync; private long completedSync, completedAsync, failedAsync;
public CompletionManager(ConnectionMultiplexer multiplexer, string name) public CompletionManager(ConnectionMultiplexer multiplexer, string name)
{ {
this.multiplexer = multiplexer; this.multiplexer = multiplexer;
this.name = name; this.name = name;
} }
public void CompleteSyncOrAsync(ICompletable operation) public void CompleteSyncOrAsync(ICompletable operation)
{ {
if (operation == null) return; if (operation == null) return;
...@@ -30,7 +31,6 @@ public void CompleteSyncOrAsync(ICompletable operation) ...@@ -30,7 +31,6 @@ public void CompleteSyncOrAsync(ICompletable operation)
{ {
multiplexer.Trace("Completed synchronously: " + operation, name); multiplexer.Trace("Completed synchronously: " + operation, name);
Interlocked.Increment(ref completedSync); Interlocked.Increment(ref completedSync);
return;
} }
else else
{ {
...@@ -57,6 +57,7 @@ public void CompleteSyncOrAsync(ICompletable operation) ...@@ -57,6 +57,7 @@ public void CompleteSyncOrAsync(ICompletable operation)
} }
} }
} }
internal void GetCounters(ConnectionCounters counters) internal void GetCounters(ConnectionCounters counters)
{ {
lock (asyncCompletionQueue) lock (asyncCompletionQueue)
...@@ -127,7 +128,7 @@ private void ProcessAsyncCompletionQueueImpl() ...@@ -127,7 +128,7 @@ private void ProcessAsyncCompletionQueueImpl()
Thread.Sleep(1); Thread.Sleep(1);
} }
int total = 0; int total = 0;
do while (true)
{ {
ICompletable next; ICompletable next;
lock (asyncCompletionQueue) lock (asyncCompletionQueue)
...@@ -163,7 +164,7 @@ private void ProcessAsyncCompletionQueueImpl() ...@@ -163,7 +164,7 @@ private void ProcessAsyncCompletionQueueImpl()
Interlocked.Increment(ref failedAsync); Interlocked.Increment(ref failedAsync);
} }
total++; total++;
} while (true); }
multiplexer.Trace("Async completion worker processed " + total + " operations", name); multiplexer.Trace("Async completion worker processed " + total + " operations", name);
} }
finally finally
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment