aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-12-12 14:21:53 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-12-12 14:21:53 +0000
commit4a9e5b2671764caddc3c5574d7643be4047e0540 (patch)
tree55a3985b45d27be07cb3d25f85b0cb7dda1df20b
parent3d837d7d12392766ec430e61a38a314e9587fec0 (diff)
Keep the original task in a shared_ptr in the wrapping lambda and make a copy of it and pass to the actual task diaptch on another executor to ensure lifetime.
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp b/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp
index 3f94247fa7e..40f8cd19a17 100644
--- a/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/scheduled_forward_executor.cpp
@@ -24,8 +24,9 @@ IScheduledExecutor::Handle
ScheduledForwardExecutor::scheduleAtFixedRate(Executor::Task::UP task,
duration delay, duration interval)
{
- return _scheduler.scheduleAtFixedRate(makeLambdaTask([&, my_task = std::move(task)]() {
- _executor.execute(makeLambdaTask([&]() {
+ std::shared_ptr<Executor::Task> my_task = std::move(task);
+ return _scheduler.scheduleAtFixedRate(makeLambdaTask([&, my_task = std::move(my_task)]() {
+ _executor.execute(makeLambdaTask([&, my_task]() {
my_task->run();
}));
}), delay, interval);