提交 727289cb 编写于 作者: N Nikolai Kochetov

Destroy resurces captured by lambda after ThreadFromGlobalPool::join().

上级 a2c70c46
......@@ -11,6 +11,7 @@
#include <Poco/Event.h>
#include <Common/ThreadStatus.h>
#include <ext/scope_guard.h>
/** Very simple thread pool similar to boost::threadpool.
......@@ -161,21 +162,21 @@ public:
GlobalThreadPool::instance().scheduleOrThrow([
state = state,
func = std::forward<Function>(func),
args = std::make_tuple(std::forward<Args>(args)...)]
args = std::make_tuple(std::forward<Args>(args)...)]() mutable
{
SCOPE_EXIT({
/// Destroy function before exit.
/// Destroy function before exit.
/// It will guarantee that after ThreadFromGlobalPool::join all captured params are destroyed.
func = {};
state->set();
});
auto function = std::move(func);
auto arguments = std::move(args);
/// Thread status holds raw pointer on query context, thus it always must be destroyed
/// before sending signal that permits to join this thread.
DB::ThreadStatus thread_status;
std::apply(func, arguments);
std::apply(function, arguments);
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册