From bf1f123b09ec7402b0565808619e11b5bfe6b16b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 14 Aug 2017 22:42:17 +0200 Subject: Progress indicator: Show number of active items --- src/libutil/util.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libutil/util.hh') diff --git a/src/libutil/util.hh b/src/libutil/util.hh index f37f2c5d1be5..35909c8d5b31 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -462,4 +462,18 @@ struct ReceiveInterrupts { } }; + + +/* A RAII helper that increments a counter on construction and + decrements it on destruction. */ +template +struct MaintainCount +{ + T & counter; + long delta; + MaintainCount(T & counter, long delta = 1) : counter(counter), delta(delta) { counter += delta; } + ~MaintainCount() { counter -= delta; } +}; + + } -- cgit 1.4.1