From 93e6d182228abc13cef214312bca14e3da881bed Mon Sep 17 00:00:00 2001 From: Daniil Komarevtsev Date: Sat, 14 Sep 2024 15:26:48 +0000 Subject: [PATCH] Switch coroutine wait to CondVar --- .../libs/endpoints_vhost/external_vhost_server.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cloud/blockstore/libs/endpoints_vhost/external_vhost_server.cpp b/cloud/blockstore/libs/endpoints_vhost/external_vhost_server.cpp index ff9c6472d32..3806febe81c 100644 --- a/cloud/blockstore/libs/endpoints_vhost/external_vhost_server.cpp +++ b/cloud/blockstore/libs/endpoints_vhost/external_vhost_server.cpp @@ -599,7 +599,7 @@ class TEndpoint final void Start() override { - auto processStarted = NewPromise(); + TCondVar processStarted; // To avoid a race, we need to get the shared pointer in the calling // thread and pass it to the background thread. This guaranteed that the // background thread will deal with a live this. @@ -610,14 +610,16 @@ class TEndpoint final // PR_SET_PDEATHSIG which tracks the aliveness of the thread that // spawned the process. self->Process = self->StartProcess(); - processStarted.SetValue(); + processStarted.Signal(); self->ThreadProc(); }; - std::thread(std::move(workFunc)).detach(); - // Infinite time wait is safe here, since we are in the coroutine - // thread. - Executor->WaitFor(processStarted); + with_lock (Mutex) { + std::thread(std::move(workFunc)).detach(); + // Infinite time wait is safe here, since we are in the coroutine + // thread. + processStarted.WaitI(Mutex); + } } TFuture Stop() override