diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-14T20·42+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-16T18·56+0200 |
commit | bf1f123b09ec7402b0565808619e11b5bfe6b16b (patch) | |
tree | d0e4c9af039b8bf05244f648907c21274ee37054 /src/libutil/util.hh | |
parent | 0e0dcf2c7ec054f1b30629e275f53f56039b8257 (diff) |
Progress indicator: Show number of active items
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 14 |
1 files changed, 14 insertions, 0 deletions
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<typename T> +struct MaintainCount +{ + T & counter; + long delta; + MaintainCount(T & counter, long delta = 1) : counter(counter), delta(delta) { counter += delta; } + ~MaintainCount() { counter -= delta; } +}; + + } |