Skip to content

Commit

Permalink
Expose MaxUsagesPerEngine as an configuration option in React.NET (#416)
Browse files Browse the repository at this point in the history
Expose MaxUsagesPerEngine as an configuration option in React.NET
  • Loading branch information
Halstatt authored and Daniel15 committed Jul 2, 2017
1 parent ec630a5 commit 5cdd2f4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/React.Core/IReactSiteConfiguration.cs
Expand Up @@ -102,6 +102,17 @@ public interface IReactSiteConfiguration
/// </summary>
IReactSiteConfiguration SetMaxEngines(int? maxEngines);

/// <summary>
/// Gets or sets the maximum number of times an engine can be reused before it is disposed.
/// <c>0</c> is unlimited. Defaults to <c>100</c>.
/// </summary>
int? MaxUsagesPerEngine { get; set; }
/// <summary>
/// Sets the maximum number of times an engine can be reused before it is disposed.
/// <c>0</c> is unlimited. Defaults to <c>100</c>.
/// </summary>
IReactSiteConfiguration SetMaxUsagesPerEngine(int? maxUsagesPerEngine);

/// <summary>
/// Gets or sets whether the MSIE engine should be used if V8 is unavailable.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/React.Core/JavaScriptEngineFactory.cs
Expand Up @@ -100,6 +100,10 @@ protected virtual IJsPool CreatePool()
{
poolConfig.StartEngines = _config.StartEngines.Value;
}
if (_config.MaxUsagesPerEngine != null)
{
poolConfig.MaxUsagesPerEngine = _config.MaxUsagesPerEngine.Value;
}

var pool = new JsPool(poolConfig);
// Reset the recycle exception on recycle. If there *are* errors loading the scripts
Expand Down
15 changes: 15 additions & 0 deletions src/React.Core/ReactSiteConfiguration.cs
Expand Up @@ -191,6 +191,21 @@ public IReactSiteConfiguration SetMaxEngines(int? maxEngines)
return this;
}

/// <summary>
/// Gets or sets the maximum number of times an engine can be reused before it is disposed.
/// <c>0</c> is unlimited. Defaults to <c>100</c>.
/// </summary>
public int? MaxUsagesPerEngine { get; set; }
/// <summary>
/// Sets the maximum number of times an engine can be reused before it is disposed.
/// <c>0</c> is unlimited. Defaults to <c>100</c>.
/// </summary>
public IReactSiteConfiguration SetMaxUsagesPerEngine(int? maxUsagesPerEngine)
{
MaxUsagesPerEngine = maxUsagesPerEngine;
return this;
}

/// <summary>
/// Gets or sets whether the MSIE engine should be used if V8 is unavailable.
/// </summary>
Expand Down

0 comments on commit 5cdd2f4

Please sign in to comment.