From ab0379f7f523448d979e72fb48075e6d4b04928a Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:45:18 +0800 Subject: [PATCH] fix timeout not init safety_flag --- include/sled/task_queue/pending_task_safety_flag.h | 2 +- src/timer/task_queue_timeout.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/sled/task_queue/pending_task_safety_flag.h b/include/sled/task_queue/pending_task_safety_flag.h index e1d5e4e..f1c1170 100644 --- a/include/sled/task_queue/pending_task_safety_flag.h +++ b/include/sled/task_queue/pending_task_safety_flag.h @@ -54,7 +54,7 @@ private: inline std::function SafeTask(scoped_refptr flag, std::function task) { - return [task, flag]() mutable { + return [flag, task]() mutable { if (flag->alive()) { std::move(task)(); } }; } diff --git a/src/timer/task_queue_timeout.cc b/src/timer/task_queue_timeout.cc index 3ef1eb2..2599232 100644 --- a/src/timer/task_queue_timeout.cc +++ b/src/timer/task_queue_timeout.cc @@ -7,7 +7,8 @@ namespace sled { TaskQueueTimeoutFactory::TaskQueueTimeout::TaskQueueTimeout(TaskQueueTimeoutFactory &parent, sled::TaskQueueBase::DelayPrecision precision) : parent_(parent), - precision_(precision) + precision_(precision), + safety_flag_(PendingTaskSafetyFlag::Create()) {} TaskQueueTimeoutFactory::TaskQueueTimeout::~TaskQueueTimeout() {}