Skip to content

Commit

Permalink
Removed use of ConcurrentDictionary in .NET client.
Browse files Browse the repository at this point in the history
- Just use a regular dictionary with locks.
- Remove dependency on tasks package.
- Removed silverlight 4 project.
- Removed core project and client project from SL solution.
  • Loading branch information
davidfowl committed Nov 17, 2012
1 parent 91e4f61 commit b0f7b14
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 284 deletions.
22 changes: 2 additions & 20 deletions Microsoft.AspNet.SignalR.Silverlight.sln
@@ -1,18 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SignalR.Core", "src\Microsoft.AspNet.SignalR.Core\Microsoft.AspNet.SignalR.Core.csproj", "{1B9A82C4-BCA1-4834-A33E-226F17BE070B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SignalR.Client", "src\Microsoft.AspNet.SignalR.Client\Microsoft.AspNet.SignalR.Client.csproj", "{EB46B9C6-EE37-48F9-835E-E49580E40E0A}"
EndProject
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{1E4BA77C-4977-40AA-B297-3A2CB9990ABF}"
ProjectSection(SolutionItems) = preProject
Build\Build.proj = Build\Build.proj
ReleaseNotes.md = ReleaseNotes.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SignalR.Client.Silverlight", "src\Microsoft.AspNet.SignalR.Client.Silverlight\Microsoft.AspNet.SignalR.Client.Silverlight.csproj", "{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SignalR.Client.Silverlight5", "src\Microsoft.AspNet.SignalR.Client.Silverlight5\Microsoft.AspNet.SignalR.Client.Silverlight5.csproj", "{0220B607-1686-4D4A-AEF0-292EA9827531}"
EndProject
Global
Expand All @@ -21,18 +15,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B9A82C4-BCA1-4834-A33E-226F17BE070B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B9A82C4-BCA1-4834-A33E-226F17BE070B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B9A82C4-BCA1-4834-A33E-226F17BE070B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B9A82C4-BCA1-4834-A33E-226F17BE070B}.Release|Any CPU.Build.0 = Release|Any CPU
{EB46B9C6-EE37-48F9-835E-E49580E40E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB46B9C6-EE37-48F9-835E-E49580E40E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB46B9C6-EE37-48F9-835E-E49580E40E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB46B9C6-EE37-48F9-835E-E49580E40E0A}.Release|Any CPU.Build.0 = Release|Any CPU
{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C55F7A30-5F93-4837-A13A-8DA06C8A2A3C}.Release|Any CPU.Build.0 = Release|Any CPU
{0220B607-1686-4D4A-AEF0-292EA9827531}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0220B607-1686-4D4A-AEF0-292EA9827531}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0220B607-1686-4D4A-AEF0-292EA9827531}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -55,10 +55,6 @@
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.4.5.4\lib\sl4\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.SL5, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\System.Threading.Tasks.3.0.1\lib\sl50\System.Threading.Tasks.SL5.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
Expand Down
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.4" />
<package id="System.Threading.Tasks" version="3.0.1" />
</packages>
3 changes: 1 addition & 2 deletions src/Microsoft.AspNet.SignalR.Client/Connection.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
Expand Down Expand Up @@ -109,7 +108,7 @@ public Connection(string url, string queryString)
Url = url;
QueryString = queryString;
_groups = new HashSet<string>();
Items = new ConcurrentDictionary<string, object>(StringComparer.OrdinalIgnoreCase);
Items = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
State = ConnectionState.Disconnected;
}

Expand Down
9 changes: 6 additions & 3 deletions src/Microsoft.AspNet.SignalR.Client/ConnectionExtensions.cs
Expand Up @@ -19,10 +19,13 @@ public static T GetValue<T>(this IConnection connection, string key)
throw new ArgumentNullException("key");
}

object value;
if (connection.Items.TryGetValue(key, out value))
lock (connection.Items)
{
return (T)value;
object value;
if (connection.Items.TryGetValue(key, out value))
{
return (T)value;
}
}

return default(T);
Expand Down
Expand Up @@ -154,7 +154,10 @@ protected virtual Action<IRequest> PrepareRequest(IConnection connection)
// Setup the user agent along with any other defaults
connection.PrepareRequest(request);
connection.Items[HttpRequestKey] = request;
lock (connection.Items)
{
connection.Items[HttpRequestKey] = request;
}
};
}

Expand Down
Expand Up @@ -79,8 +79,11 @@ private void PollingLoop(IConnection connection, string data, Action initializeC

HttpClient.PostAsync(url, PrepareRequest(connection)).ContinueWith(task =>
{
// Clear the pending request
connection.Items.Remove(HttpRequestKey);
lock (connection.Items)
{
// Clear the pending request
connection.Items.Remove(HttpRequestKey);
}
bool shouldRaiseReconnect = false;
bool disconnectedReceived = false;
Expand Down
Expand Up @@ -107,7 +107,10 @@ private void OpenConnection(IConnection connection, string data, Action initiali
var eventSource = new EventSourceStreamReader(stream);
bool retry = true;
connection.Items[EventSourceKey] = eventSource;
lock (connection.Items)
{
connection.Items[EventSourceKey] = eventSource;
}
eventSource.Opened = () =>
{
Expand Down

0 comments on commit b0f7b14

Please sign in to comment.