From 40f62719ff5fedc7ee1a41b87e5abef2751638cb Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Thu, 15 Oct 2020 13:24:18 +0300 Subject: [PATCH] Move event to stack. --- src/Common/ThreadPool.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Common/ThreadPool.h b/src/Common/ThreadPool.h index eb385547fa8..8dd6cbbe02c 100644 --- a/src/Common/ThreadPool.h +++ b/src/Common/ThreadPool.h @@ -164,7 +164,8 @@ public: func = std::forward(func), args = std::make_tuple(std::forward(args)...)]() mutable /// mutable is needed to destroy capture { - SCOPE_EXIT(state->set()); + auto event = std::move(state); + SCOPE_EXIT(event->set()); /// This moves are needed to destroy function and arguments before exit. /// It will guarantee that after ThreadFromGlobalPool::join all captured params are destroyed.