! Start the thread and run all its functions in sequence. \param init Argument for first function in the thread */
| 452 | \param init Argument for first function in the thread |
| 453 | */ |
| 454 | void start(QVariant init = QVariant()) |
| 455 | { |
| 456 | if (!m_hasOwner || m_owner.isNull()) |
| 457 | { |
| 458 | BinaryNinja::LogDebug("Starting background thread with no owning object. This is technically allowed but it might outlive any UIs it changes."); |
| 459 | } |
| 460 | if (m_then.empty() && m_catch.empty() && m_finally.empty()) |
| 461 | { |
| 462 | std::unique_lock lock(m_finishLock); |
| 463 | m_finished = true; |
| 464 | deleteLater(); |
| 465 | return; |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | m_init = init; |
| 470 | m_future = QtConcurrent::run([&] { |
| 471 | runThread(); |
| 472 | { |
| 473 | std::unique_lock lock(m_finishLock); |
| 474 | m_finished = true; |
| 475 | } |
| 476 | deleteLater(); |
| 477 | }); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | /*! |
| 482 | Block until the thread finishes |