Skip to content

Commit

Permalink
Resolve start script configuration in parallel mode without a delay t…
Browse files Browse the repository at this point in the history
…o avoid messing with changing variables.
  • Loading branch information
JMS-1 committed Oct 14, 2024
1 parent c8874cc commit 12eaab6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 1 addition & 4 deletions Library/Extensions/RunParallel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public class RunParallel : Block
var leading = await Values.EvaluateAsync<double?>("LEADINGSCRIPT", context, false);

/* Request configuration for all scripts - allow empty array elements. */
var configs = new List<StartScript>();

foreach (RunScript script in scripts)
configs.Add(await script.ReadConfigurationAsync(context));
var configs = scripts.Cast<StartScript>().ToList();

/* Lifetime control. */
var leadingDone = false;
Expand Down
11 changes: 7 additions & 4 deletions Library/Extensions/RunScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class RunScript : Block
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task<StartScript> ReadConfigurationAsync(Context context)
private async Task<StartScript> ReadConfigurationAsync(Context context)
{
/* Find the script by its name - character casing is ignored. */
var store = context.ServiceProvider.GetRequiredService<IScriptDefinitionStorage>();
Expand All @@ -111,16 +111,19 @@ public async Task<StartScript> ReadConfigurationAsync(Context context)
/// <inheritdoc/>
public override async Task<object?> EvaluateAsync(Context context)
{
/* Convert the configuration. */
var config = await ReadConfigurationAsync(context);

/* We are prepared to be run in parallel to other scripts. */
if (context.ParallelMode > 0) return this;
if (context.ParallelMode > 0) return config;

/* Or we are hust building. */
var buildOnly = await Values.EvaluateAsync<bool?>("BUILDONLY", context, true);

if (buildOnly == true) return this;
if (buildOnly == true) return config;

/* Run the script and report the result - in a new isolated environment. */
var result = await context.Engine.RunAsync<GenericResult>(await ReadConfigurationAsync(context));
var result = await context.Engine.RunAsync<GenericResult>(config);

return result.Result;
}
Expand Down

0 comments on commit 12eaab6

Please sign in to comment.