fix timeout not init safety_flag
All checks were successful
linux-x64-gcc / linux-gcc (Release) (push) Successful in 1m29s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 1m28s

This commit is contained in:
tqcq 2024-03-19 15:45:18 +08:00
parent d716ac684e
commit ab0379f7f5
2 changed files with 3 additions and 2 deletions

View File

@ -54,7 +54,7 @@ private:
inline std::function<void()> inline std::function<void()>
SafeTask(scoped_refptr<PendingTaskSafetyFlag> flag, std::function<void()> task) SafeTask(scoped_refptr<PendingTaskSafetyFlag> flag, std::function<void()> task)
{ {
return [task, flag]() mutable { return [flag, task]() mutable {
if (flag->alive()) { std::move(task)(); } if (flag->alive()) { std::move(task)(); }
}; };
} }

View File

@ -7,7 +7,8 @@ namespace sled {
TaskQueueTimeoutFactory::TaskQueueTimeout::TaskQueueTimeout(TaskQueueTimeoutFactory &parent, TaskQueueTimeoutFactory::TaskQueueTimeout::TaskQueueTimeout(TaskQueueTimeoutFactory &parent,
sled::TaskQueueBase::DelayPrecision precision) sled::TaskQueueBase::DelayPrecision precision)
: parent_(parent), : parent_(parent),
precision_(precision) precision_(precision),
safety_flag_(PendingTaskSafetyFlag::Create())
{} {}
TaskQueueTimeoutFactory::TaskQueueTimeout::~TaskQueueTimeout() {} TaskQueueTimeoutFactory::TaskQueueTimeout::~TaskQueueTimeout() {}