Warn if PostgreSQL appears stalled

This commit is contained in:
Eelco Dolstra
2016-02-29 15:10:30 +01:00
parent 922dc541c2
commit 7cd08c7c46
5 changed files with 32 additions and 0 deletions
+5
View File
@@ -1,6 +1,7 @@
#pragma once
#include <atomic>
#include <functional>
typedef std::atomic<unsigned long> counter;
@@ -8,5 +9,9 @@ struct MaintainCount
{
counter & c;
MaintainCount(counter & c) : c(c) { c++; }
MaintainCount(counter & c, std::function<void(unsigned long)> warn) : c(c)
{
warn(++c);
}
~MaintainCount() { auto prev = c--; assert(prev); }
};