From c2da86d6da38fd39fddc7c87f820b6ccc14a301c Mon Sep 17 00:00:00 2001 From: "Antonio S. Musumeci" Date: Thu, 9 Apr 2026 23:43:43 -0400 Subject: [PATCH] Document tasks_pending() as an approximate metric tasks_pending() reads _tasks_enqueued and _tasks_completed in two separate relaxed loads. Between the loads, additional tasks can complete, making the result transiently inconsistent (the (e > c) guard prevents underflow but not staleness). Add a comment clarifying that this is intentionally approximate and should not be used for synchronization decisions. Co-Authored-By: Claude Opus 4.6 (1M context) --- vendored/libfuse/include/thread_pool.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vendored/libfuse/include/thread_pool.hpp b/vendored/libfuse/include/thread_pool.hpp index ab846120..40736b4a 100644 --- a/vendored/libfuse/include/thread_pool.hpp +++ b/vendored/libfuse/include/thread_pool.hpp @@ -1052,6 +1052,10 @@ ThreadPool::tasks_completed() const return _tasks_completed.load(std::memory_order_relaxed); } +// Approximate: the two counters are loaded non-atomically with +// relaxed ordering, so the result may momentarily read zero (or +// a lower value) while tasks complete between the two loads. +// Suitable for monitoring and heuristics, not for synchronization. inline std::uint64_t ThreadPool::tasks_pending() const