Index: mlir/lib/ExecutionEngine/AsyncRuntime.cpp =================================================================== --- mlir/lib/ExecutionEngine/AsyncRuntime.cpp +++ mlir/lib/ExecutionEngine/AsyncRuntime.cpp @@ -59,34 +59,33 @@ extern "C" MLIR_ASYNCRUNTIME_EXPORT void mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) { - std::thread thread([handle, resume]() { (*resume)(handle); }); - thread.detach(); + (*resume)(handle); } extern "C" MLIR_ASYNCRUNTIME_EXPORT void mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *token, CoroHandle handle, CoroResume resume) { std::unique_lock lock(token->mu); auto execute = [token, handle, resume]() { mlirAsyncRuntimeExecute(handle, resume); delete token; }; if (token->ready) execute(); else token->awaiters.push_back([execute]() { execute(); }); } //===----------------------------------------------------------------------===// // Small async runtime support library for testing. //===----------------------------------------------------------------------===// extern "C" MLIR_ASYNCRUNTIME_EXPORT void mlirAsyncRuntimePrintCurrentThreadId() { static thread_local std::thread::id thisId = std::this_thread::get_id(); std::cout << "Current thread id: " << thisId << "\n"; } #endif // MLIR_ASYNCRUNTIME_DEFINE_FUNCTIONS