Skip to content

Commit

Permalink
Upgrade to JSPool 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 committed Jul 2, 2017
1 parent 5168caa commit 1972c59
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 57 deletions.
4 changes: 2 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ of patent rights can be found in the PATENTS file in the same directory.
<Project ToolsVersion="4.0" DefaultTargets="Build;Test;Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Major>3</Major>
<Minor>0</Minor>
<Build>1</Build>
<Minor>1</Minor>
<Build>0</Build>
<Revision>0</Revision>
<DevNuGetServer>http://reactjs.net/packages/</DevNuGetServer>
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\tools\MSBuildTasks</MSBuildCommunityTasksPath>
Expand Down
8 changes: 4 additions & 4 deletions src/React.Core/IJavaScriptEngineFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.Core;
using JSPool;

namespace React
{
Expand All @@ -25,12 +25,12 @@ public interface IJavaScriptEngineFactory
/// Gets a JavaScript engine from the pool.
/// </summary>
/// <returns>The JavaScript engine</returns>
IJsEngine GetEngine();
PooledJsEngine GetEngine();

/// <summary>
/// Returns an engine to the pool so it can be reused
/// </summary>
/// <param name="engine">Engine to return</param>
void ReturnEngineToPool(IJsEngine engine);
void ReturnEngineToPool(PooledJsEngine engine);
}
}
6 changes: 3 additions & 3 deletions src/React.Core/JavaScriptEngineFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public virtual void DisposeEngineForCurrentThread()
/// Gets a JavaScript engine from the pool.
/// </summary>
/// <returns>The JavaScript engine</returns>
public virtual IJsEngine GetEngine()
public virtual PooledJsEngine GetEngine()
{
EnsureValidState();
return _pool.GetEngine();
Expand All @@ -233,13 +233,13 @@ public virtual IJsEngine GetEngine()
/// Returns an engine to the pool so it can be reused
/// </summary>
/// <param name="engine">Engine to return</param>
public virtual void ReturnEngineToPool(IJsEngine engine)
public virtual void ReturnEngineToPool(PooledJsEngine engine)
{
// This could be called from ReactEnvironment.Dispose if that class is disposed after
// this class. Let's just ignore this if it's disposed.
if (!_disposed)
{
_pool.ReturnEngineToPool(engine);
engine.Dispose();
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/React.Core/React.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore" Version="2.3.2" />
<PackageReference Include="JavaScriptEngineSwitcher.Core" Version="2.2.0" />
<PackageReference Include="JavaScriptEngineSwitcher.Msie" Version="2.3.2" />
<PackageReference Include="JSPool" Version="2.0.1" />
<PackageReference Include="MsieJavaScriptEngine" Version="2.1.2" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore" Version="2.4.8" />
<PackageReference Include="JavaScriptEngineSwitcher.Core" Version="2.4.9" />
<PackageReference Include="JavaScriptEngineSwitcher.Msie" Version="2.4.9" />
<PackageReference Include="JSPool" Version="3.0.1" />
<PackageReference Include="MsieJavaScriptEngine" Version="2.2.2" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<PackageReference Include="JavaScriptEngineSwitcher.V8" Version="2.2.0" />
<PackageReference Include="JavaScriptEngineSwitcher.V8" Version="2.4.2" />
<PackageReference Include="VroomJs" Version="1.2.3" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System" />
Expand Down
7 changes: 4 additions & 3 deletions src/React.Core/ReactEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Threading;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.Core.Helpers;
using JSPool;
using Newtonsoft.Json;
using React.Exceptions;

Expand Down Expand Up @@ -68,7 +69,7 @@ public class ReactEnvironment : IReactEnvironment, IDisposable
/// Contains an engine acquired from a pool of engines. Only used if
/// <see cref="IReactSiteConfiguration.ReuseJavaScriptEngines"/> is enabled.
/// </summary>
protected Lazy<IJsEngine> _engineFromPool;
protected Lazy<PooledJsEngine> _engineFromPool;

/// <summary>
/// List of all components instantiated in this environment
Expand Down Expand Up @@ -108,7 +109,7 @@ IFileCacheHash fileCacheHash
_babelTransformer = new Lazy<IBabel>(() =>
new Babel(this, _cache, _fileSystem, _fileCacheHash, _config)
);
_engineFromPool = new Lazy<IJsEngine>(() => _engineFactory.GetEngine());
_engineFromPool = new Lazy<PooledJsEngine>(() => _engineFactory.GetEngine());
}

/// <summary>
Expand Down Expand Up @@ -400,7 +401,7 @@ public void ReturnEngineToPool()
if (_engineFromPool.IsValueCreated)
{
_engineFactory.ReturnEngineToPool(_engineFromPool.Value);
_engineFromPool = new Lazy<IJsEngine>(() => _engineFactory.GetEngine());
_engineFromPool = new Lazy<PooledJsEngine>(() => _engineFactory.GetEngine());
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/React.Sample.Cassette/React.Sample.Cassette.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@
<HintPath>..\packages\Cassette.Views.2.4.2\lib\net40\Cassette.Views.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Core.2.2.0\lib\net40-client\JavaScriptEngineSwitcher.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="JavaScriptEngineSwitcher.Core, Version=2.4.9.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Core.2.4.9\lib\net40-client\JavaScriptEngineSwitcher.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion src/React.Sample.Cassette/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<package id="Cassette.Aspnet" version="2.4.2" targetFramework="net40" />
<package id="Cassette.MSBuild" version="2.4.2" targetFramework="net40" />
<package id="Cassette.Views" version="2.4.2" targetFramework="net40" />
<package id="JavaScriptEngineSwitcher.Core" version="2.2.0" targetFramework="net40" />
<package id="JavaScriptEngineSwitcher.Core" version="2.4.9" targetFramework="net40" />
<package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net40" />
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" targetFramework="net40" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net40" />
Expand Down
25 changes: 10 additions & 15 deletions src/React.Sample.Mvc4/React.Sample.Mvc4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,21 @@
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ClearScript, Version=5.4.8.0, Culture=neutral, PublicKeyToken=935d0c957da47c73, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.2.0\lib\net45\ClearScript.dll</HintPath>
<Private>True</Private>
<Reference Include="ClearScript, Version=5.4.9.0, Culture=neutral, PublicKeyToken=935d0c957da47c73, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.4.2\lib\net45\ClearScript.dll</HintPath>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Core.2.2.0\lib\net45\JavaScriptEngineSwitcher.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="JavaScriptEngineSwitcher.Core, Version=2.4.9.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Core.2.4.9\lib\net45\JavaScriptEngineSwitcher.Core.dll</HintPath>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.Msie, Version=2.3.2.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Msie.2.3.2\lib\net45\JavaScriptEngineSwitcher.Msie.dll</HintPath>
<Private>True</Private>
<Reference Include="JavaScriptEngineSwitcher.Msie, Version=2.4.9.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Msie.2.4.9\lib\net45\JavaScriptEngineSwitcher.Msie.dll</HintPath>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.V8, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.2.0\lib\net45\JavaScriptEngineSwitcher.V8.dll</HintPath>
<Private>True</Private>
<Reference Include="JavaScriptEngineSwitcher.V8, Version=2.4.2.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.4.2\lib\net45\JavaScriptEngineSwitcher.V8.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="MsieJavaScriptEngine, Version=2.1.2.0, Culture=neutral, PublicKeyToken=a3a2846a37ac0d3e, processorArchitecture=MSIL">
<HintPath>..\packages\MsieJavaScriptEngine.2.1.2\lib\net45\MsieJavaScriptEngine.dll</HintPath>
<Private>True</Private>
<Reference Include="MsieJavaScriptEngine, Version=2.2.2.0, Culture=neutral, PublicKeyToken=a3a2846a37ac0d3e, processorArchitecture=MSIL">
<HintPath>..\packages\MsieJavaScriptEngine.2.2.2\lib\net45\MsieJavaScriptEngine.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/React.Sample.Mvc4/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="JavaScriptEngineSwitcher.Core" publicKeyToken="c608b2a8cc9e4472" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
<bindingRedirect oldVersion="0.0.0.0-2.4.9.0" newVersion="2.4.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
Expand Down
8 changes: 4 additions & 4 deletions src/React.Sample.Mvc4/packages.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="JavaScriptEngineSwitcher.Core" version="2.2.0" targetFramework="net45" />
<package id="JavaScriptEngineSwitcher.Msie" version="2.3.2" targetFramework="net45" />
<package id="JavaScriptEngineSwitcher.V8" version="2.2.0" targetFramework="net45" />
<package id="JavaScriptEngineSwitcher.Core" version="2.4.9" targetFramework="net45" />
<package id="JavaScriptEngineSwitcher.Msie" version="2.4.9" targetFramework="net45" />
<package id="JavaScriptEngineSwitcher.V8" version="2.4.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net4" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net4" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net4" />
<package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net4" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net4" />
<package id="MsieJavaScriptEngine" version="2.1.2" targetFramework="net45" />
<package id="MsieJavaScriptEngine" version="2.2.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="WebActivatorEx" version="2.2.0" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/React.Sample.Mvc6/React.Sample.Mvc6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<PackageReference Include="JavaScriptEngineSwitcher.V8" Version="2.2.0" />
<PackageReference Include="JavaScriptEngineSwitcher.V8" Version="2.4.2" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand Down
15 changes: 6 additions & 9 deletions src/React.Sample.Webpack/React.Sample.Webpack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,14 @@
<NoWarn>1607</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="ClearScript, Version=5.4.8.0, Culture=neutral, PublicKeyToken=935d0c957da47c73, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.2.0\lib\net40-client\ClearScript.dll</HintPath>
<Private>True</Private>
<Reference Include="ClearScript, Version=5.4.9.0, Culture=neutral, PublicKeyToken=935d0c957da47c73, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.4.2\lib\net40-client\ClearScript.dll</HintPath>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Core.2.2.0\lib\net40-client\JavaScriptEngineSwitcher.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="JavaScriptEngineSwitcher.Core, Version=2.4.9.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Core.2.4.9\lib\net40-client\JavaScriptEngineSwitcher.Core.dll</HintPath>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.V8, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.2.0\lib\net40-client\JavaScriptEngineSwitcher.V8.dll</HintPath>
<Private>True</Private>
<Reference Include="JavaScriptEngineSwitcher.V8, Version=2.4.2.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.2.4.2\lib\net40-client\JavaScriptEngineSwitcher.V8.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion src/React.Sample.Webpack/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="JavaScriptEngineSwitcher.Core" publicKeyToken="c608b2a8cc9e4472" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
<bindingRedirect oldVersion="0.0.0.0-2.4.9.0" newVersion="2.4.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="JavaScriptEngineSwitcher.V8" publicKeyToken="c608b2a8cc9e4472" culture="neutral" />
Expand Down
4 changes: 2 additions & 2 deletions src/React.Sample.Webpack/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="JavaScriptEngineSwitcher.Core" version="2.2.0" targetFramework="net40" />
<package id="JavaScriptEngineSwitcher.V8" version="2.2.0" targetFramework="net40" />
<package id="JavaScriptEngineSwitcher.Core" version="2.4.9" targetFramework="net40" />
<package id="JavaScriptEngineSwitcher.V8" version="2.4.2" targetFramework="net40" />
<package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net40" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net40" />
Expand Down
5 changes: 3 additions & 2 deletions tests/React.Tests/Core/ReactEnvironmentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using JavaScriptEngineSwitcher.Core;
using JSPool;
using Moq;
using Xunit;
using React.Exceptions;
Expand Down Expand Up @@ -124,15 +125,15 @@ public void ReturnsEngineToPool()

private class Mocks
{
public Mock<IJsEngine> Engine { get; private set; }
public Mock<PooledJsEngine> Engine { get; private set; }
public Mock<IJavaScriptEngineFactory> EngineFactory { get; private set; }
public Mock<IReactSiteConfiguration> Config { get; private set; }
public Mock<ICache> Cache { get; private set; }
public Mock<IFileSystem> FileSystem { get; private set; }
public Mock<IFileCacheHash> FileCacheHash { get; private set; }
public Mocks()
{
Engine = new Mock<IJsEngine>();
Engine = new Mock<PooledJsEngine>();
EngineFactory = new Mock<IJavaScriptEngineFactory>();
Config = new Mock<IReactSiteConfiguration>();
Cache = new Mock<ICache>();
Expand Down

0 comments on commit 1972c59

Please sign in to comment.