#pragma once #include namespace Cevo { // Equivalent of Threading.pas's free functions (RunInThread/ // RunInThreadAsync/Synchronize). The TVirtualThread/TListedThread/ // TTermThread/TThreadList class hierarchy is NOT ported: it exists only to // let a worker thread find "its own" wrapper object (via a global, // mutex-guarded ThreadList keyed by TThreadID) so Synchronize() can call // back into it - QThread + Qt::BlockingQueuedConnection already solve this // natively, with no registry needed. // Runs `method` on a new thread, blocking the caller until it finishes // (pumping the Qt event loop meanwhile if called from the main thread). // Re-throws whatever `method` threw. void runInThread(const std::function &method); // Runs `method` on a new thread without blocking; if given, `callback` runs // (on that same worker thread) once `method` returns. void runInThreadAsync(const std::function &method, const std::function &callback = {}); // Equivalent of TThread.Synchronize from a worker thread: runs `method` on // the main/GUI thread, blocking the caller until it completes. Runs // `method` directly, with no thread hop, if already on the main thread. void synchronizeToMainThread(const std::function &method); } // namespace Cevo