| 221 | Conductor::~Conductor() = default; |
| 222 | |
| 223 | void Conductor::handleStart(ReceiverThread *receiver, const std::string &ex_name, int ex_id, bool restarts) |
| 224 | { |
| 225 | |
| 226 | auto res = executions_.find(ex_id); |
| 227 | |
| 228 | if (res == executions_.end() || ex_id == 0) |
| 229 | { |
| 230 | |
| 231 | /// Note: metadata from MiniZinc IDE overrides that provided by the solver |
| 232 | std::string ex_name_used = ex_name; |
| 233 | |
| 234 | const bool ide_used = (exec_meta_.find(ex_id) != exec_meta_.end()); |
| 235 | |
| 236 | if (ide_used) |
| 237 | { |
| 238 | print("already know metadata for this ex_id!"); |
| 239 | ex_name_used = exec_meta_[ex_id].ex_name; |
| 240 | } |
| 241 | |
| 242 | /// needs a new execution |
| 243 | auto ex = addNewExecution(ex_name_used, ex_id, restarts); |
| 244 | emit executionStart(ex); |
| 245 | |
| 246 | /// construct a name map |
| 247 | if (ide_used) |
| 248 | { |
| 249 | ex->setNameMap(exec_meta_[ex_id].name_map); |
| 250 | print("using name map for {}", ex_id); |
| 251 | } |
| 252 | else if (options_.paths != "" && options_.mzn != "") |
| 253 | { |
| 254 | auto nm = std::make_shared<NameMap>(); |
| 255 | auto success = nm->initialize(options_.paths, options_.mzn); |
| 256 | if (success) |
| 257 | { |
| 258 | ex->setNameMap(nm); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /// The builder should only be created for a new execution |
| 263 | auto builderThread = new QThread(); |
| 264 | auto builder = new TreeBuilder(*ex); |
| 265 | |
| 266 | builders_[ex_id] = builder; |
| 267 | builder->moveToThread(builderThread); |
| 268 | |
| 269 | // onExecutionDone must be called on the same thread as the conductor |
| 270 | connect(builder, &TreeBuilder::buildingDone, this, [this, ex]() { |
| 271 | onExecutionDone(ex); |
| 272 | }); |
| 273 | |
| 274 | /// is this the right time to delete the builder thread? |
| 275 | connect(builderThread, &QThread::finished, builderThread, &QObject::deleteLater); |
| 276 | |
| 277 | builderThread->start(); |
| 278 | } |
| 279 | |
| 280 | /// obtain the builder aready assigned to this execution |
nothing calls this directly
no test coverage detected