summaryrefslogtreecommitdiff
path: root/ACE/protocols/ace/TMCast/FaultDetector.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/protocols/ace/TMCast/FaultDetector.hpp')
-rw-r--r--ACE/protocols/ace/TMCast/FaultDetector.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/ACE/protocols/ace/TMCast/FaultDetector.hpp b/ACE/protocols/ace/TMCast/FaultDetector.hpp
new file mode 100644
index 00000000000..b629cf27078
--- /dev/null
+++ b/ACE/protocols/ace/TMCast/FaultDetector.hpp
@@ -0,0 +1,44 @@
+// $Id$
+// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
+
+#include "Protocol.hpp"
+
+namespace ACE_TMCast
+{
+ class FaultDetector
+ {
+ public:
+ FaultDetector ()
+ : alone_ (true), silence_period_ (-1)
+ {
+ }
+
+ public:
+ class Failed {};
+
+
+ void
+ insync ()
+ {
+ if (alone_)
+ alone_ = false;
+
+ silence_period_ = 0;
+ }
+
+ void
+ outsync ()
+ {
+ if (!alone_ && ++silence_period_ >= Protocol::FATAL_SILENCE_FRAME)
+ {
+ // cerr << "Silence period has been passed." << endl;
+ // cerr << "Decalring the node failed." << endl;
+ throw Failed ();
+ }
+ }
+
+ private:
+ bool alone_; // true if we haven't heard from any members yet.
+ short silence_period_;
+ };
+}