From fb63bd7e06f078740676d299f4d4d3584b39b107 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 21 Jul 2025 09:48:40 -0400 Subject: [PATCH] c++20: Implicit value sharing of `this` is deprecated in C++20 Fix the handful of instances. Signed-off-by: Zygo Blaxell (cherry picked from commit 4d6b21fb40174c3ecdc9e97670dae0dd22ce74a6) --- lib/task.cc | 4 ++-- src/bees-context.cc | 6 +++--- src/bees-thread.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/task.cc b/lib/task.cc index fb90dcc..2507285 100644 --- a/lib/task.cc +++ b/lib/task.cc @@ -754,7 +754,7 @@ namespace crucible { m_prev_loadavg = getloadavg1(); if (target && !m_load_tracking_thread) { - m_load_tracking_thread = make_shared([=] () { loadavg_thread_fn(); }); + m_load_tracking_thread = make_shared([this] () { loadavg_thread_fn(); }); m_load_tracking_thread->detach(); } } @@ -944,7 +944,7 @@ namespace crucible { TaskConsumer::TaskConsumer(const shared_ptr &tms) : m_master(tms) { - m_thread = make_shared([=](){ consumer_thread(); }); + m_thread = make_shared([this](){ consumer_thread(); }); } class BarrierState { diff --git a/src/bees-context.cc b/src/bees-context.cc index 0ffa3da..e6da4fc 100644 --- a/src/bees-context.cc +++ b/src/bees-context.cc @@ -1126,15 +1126,15 @@ BeesContext::start() m_progress_thread = make_shared("progress_report"); m_progress_thread = make_shared("progress_report"); m_status_thread = make_shared("status_report"); - m_progress_thread->exec([=]() { + m_progress_thread->exec([this]() { show_progress(); }); - m_status_thread->exec([=]() { + m_status_thread->exec([this]() { dump_status(); }); // Set up temporary file pool - m_tmpfile_pool.generator([=]() -> shared_ptr { + m_tmpfile_pool.generator([this]() -> shared_ptr { return make_shared(shared_from_this()); }); m_logical_ino_pool.generator([]() { diff --git a/src/bees-thread.cc b/src/bees-thread.cc index 4445c46..62e80d8 100644 --- a/src/bees-thread.cc +++ b/src/bees-thread.cc @@ -14,7 +14,7 @@ BeesThread::exec(function func) { m_timer.reset(); BEESLOGDEBUG("BeesThread exec " << m_name); - m_thread_ptr = make_shared([=]() { + m_thread_ptr = make_shared([this, func]() { BeesNote::set_name(m_name); BEESLOGDEBUG("Starting thread " << m_name); BEESNOTE("thread function");