summaryrefslogtreecommitdiff
path: root/ace/TMCast/FaultDetector.hpp
blob: c3de622806de0b6042e9b1590d2537fd0d1a0eb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// file      : ACE_TMCast/FaultDetector.hpp
// author    : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id    : $Id$

#include "Protocol.hpp"

namespace ACE_TMCast
{
  class FaultDetector
  {
  public:
    FaultDetector ()
        : silence_period_ (-1)
    {
    }

  public:
    class Failed {};


    void
    insync ()
    {
      silence_period_ = 0;
    }

    void
    outsync ()
    {
      if (++silence_period_ >= Protocol::FATAL_SILENCE_FRAME)
      {
        // cerr << "Silence period has been passed." << endl;
        // cerr << "Decalring the node failed." << endl;
        throw Failed ();
      }
    }

  private:
    short silence_period_;
  };
}