Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose MaxUsagesPerEngine as an configuration option in React.NET #416

Merged
merged 3 commits into from Jul 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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