Quintiq file version 2.0
|
#parent: #root
|
Method CanStart () as Boolean
|
{
|
Description:
|
[*
|
This method checks if the `LibOpt_Run` that corresponds to this `LibOpt_ControllerRun` can be started.
|
This method is called every `LibOpt_OptimizerRunController.PollingDuration` milliseconds until it returns `true`.
|
*]
|
TextBody:
|
[*
|
// evr3 Apr-26-2022 (created)
|
controller := this.OptimizerRunController();
|
|
// The run that was requested the longest ago will start first, even when new runs could already start
|
// This is to ensure that new runs that request few threads won't block an old run that requests many threads.
|
canstart := controller.FirstUnstartedRun() = this
|
and controller.ConcurrentRuns() < controller.ConcurrentRunsMax()
|
and controller.CPUThreadsUsedTotal() + this.CPUThreadsRequested() <= controller.CPUThreadsMax();
|
|
if( canstart )
|
{
|
// It is very tempting to call StartRun reactively so that we can make CanStart const.
|
// However, you don't want to do that, as the start attributes need to be set in the same transaction.
|
// This ensures that CPUThreadsUsedTotal is correct when another run calls CanStart.
|
this.Start();
|
}
|
|
return canstart;
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|