Refactored a few for EndPointListener.cs

This commit is contained in:
sta 2015-01-05 16:37:14 +09:00
parent 2179b2eec1
commit 6af171ddcb

View File

@ -451,14 +451,16 @@ namespace WebSocketSharp.Net
if (prefix.Host == "*") { if (prefix.Host == "*") {
do { do {
current = _unhandled; current = _unhandled;
future = current != null if (current == null)
? new List<HttpListenerPrefix> (current) break;
: new List<HttpListenerPrefix> ();
future = new List<HttpListenerPrefix> (current);
if (!removeSpecial (future, prefix)) if (!removeSpecial (future, prefix))
break; // Prefix not found. break; // The prefix wasn't found.
} }
while (Interlocked.CompareExchange (ref _unhandled, future, current) != current); while (
Interlocked.CompareExchange<List<HttpListenerPrefix>> (
ref _unhandled, future, current) != current);
checkIfRemove (); checkIfRemove ();
return; return;
@ -467,14 +469,16 @@ namespace WebSocketSharp.Net
if (prefix.Host == "+") { if (prefix.Host == "+") {
do { do {
current = _all; current = _all;
future = current != null if (current == null)
? new List<HttpListenerPrefix> (current) break;
: new List<HttpListenerPrefix> ();
future = new List<HttpListenerPrefix> (current);
if (!removeSpecial (future, prefix)) if (!removeSpecial (future, prefix))
break; // Prefix not found. break; // The prefix wasn't found.
} }
while (Interlocked.CompareExchange (ref _all, future, current) != current); while (
Interlocked.CompareExchange<List<HttpListenerPrefix>> (
ref _all, future, current) != current);
checkIfRemove (); checkIfRemove ();
return; return;
@ -489,7 +493,9 @@ namespace WebSocketSharp.Net
prefs2 = new Dictionary<HttpListenerPrefix, HttpListener> (prefs); prefs2 = new Dictionary<HttpListenerPrefix, HttpListener> (prefs);
prefs2.Remove (prefix); prefs2.Remove (prefix);
} }
while (Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs); while (
Interlocked.CompareExchange<Dictionary<HttpListenerPrefix, HttpListener>> (
ref _prefixes, prefs2, prefs) != prefs);
checkIfRemove (); checkIfRemove ();
} }