Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/React.Core/IReactSiteConfiguration.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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