-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a sometimes failing concurrency test (#1712)
* a sometimes failing concurrency test * Fixes concurrenty issue * Fixes concurrency test Co-authored-by: Michael Sevestre <michael@design2code.ca>
- Loading branch information
1 parent
177e79c
commit ccb2b9f
Showing
6 changed files
with
68,046 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Domain.Builder; | ||
using OSPSuite.Core.Domain.Services; | ||
using OSPSuite.R.Domain; | ||
|
||
namespace OSPSuite.R.Services | ||
{ | ||
public interface ISimulationTask | ||
{ | ||
IModelCoreSimulation Clone(IModelCoreSimulation simulation); | ||
/// <summary> | ||
/// Returns a clone of the simulation that can be used during batch run. | ||
/// This simulation will contain the minimal information required to run. Configuration settings (e.g. some building blocks) will not be copied over | ||
/// </summary> | ||
/// <param name="simulation">Simulation to clone</param> | ||
IModelCoreSimulation CloneForBatchRun(IModelCoreSimulation simulation); | ||
} | ||
|
||
public class SimulationTask : ISimulationTask | ||
{ | ||
private readonly ICloneManagerForModel _cloneManagerForModel; | ||
private readonly ISimulationPersistableUpdater _simulationPersistableUpdater; | ||
|
||
public SimulationTask(ICloneManagerForModel cloneManagerForModel) | ||
public SimulationTask(ICloneManagerForModel cloneManagerForModel, ISimulationPersistableUpdater simulationPersistableUpdater) | ||
{ | ||
_cloneManagerForModel = cloneManagerForModel; | ||
_simulationPersistableUpdater = simulationPersistableUpdater; | ||
} | ||
public IModelCoreSimulation Clone(IModelCoreSimulation simulationToClone) | ||
|
||
public IModelCoreSimulation CloneForBatchRun(IModelCoreSimulation simulationToClone) | ||
{ | ||
var simulation = new ModelCoreSimulation | ||
{ | ||
Model = _cloneManagerForModel.CloneModel(simulationToClone.Model) | ||
Model = _cloneManagerForModel.CloneModel(simulationToClone.Model), | ||
// None of the other properties are required to complete the simulation | ||
// Initialize a BuildConfiguration with only SimulationSettings because some of the properties to complete the initialization are required | ||
BuildConfiguration = new BuildConfiguration | ||
{ | ||
SimulationSettings = _cloneManagerForModel.Clone(simulationToClone.SimulationSettings) | ||
} | ||
}; | ||
|
||
// Initialize a BuildConfiguration with only SimulationSettings because some of the properties to complete the initialization are required | ||
// None of the other properties are required to complete the simulation | ||
var simulationBuildConfiguration = new BuildConfiguration | ||
{ | ||
SimulationSettings = _cloneManagerForModel.Clone(simulationToClone.SimulationSettings) | ||
}; | ||
simulation.BuildConfiguration = simulationBuildConfiguration; | ||
|
||
//Once we prepare a simulation for a batch, we are assuming that it won't be changed by the caller. | ||
//We update the persistable at this stage to avoid any possible thread problems | ||
_simulationPersistableUpdater.UpdateSimulationPersistable(simulation); | ||
|
||
return simulation; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.