summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.h
blob: 0c9309f016b24e17ea3691d4ec305da941fef901 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// -*- C++ -*-

//=============================================================================
/**
 *  @file   Failure_Task.h
 *
 *  $Id$
 *
 *  @author Friedhelm Wolf <fwolf@dre.vanderbilt.edu>
 */
//=============================================================================

#ifndef FAILURE_TASK_H_
#define FAILURE_TASK_H_

#include "ace/Condition_T.h"
#include "ace/Task.h"
#include "tao/ORB.h"

/**
 * @class Failure_Task 
 *
 * @brief Active object that can be notified to simulate an
 *        application crash by shutting down the ORB.
 */

class Failure_Task : public ACE_Task_Base
{
 public:
  /// constructor
  Failure_Task (CORBA::ORB_ptr orb,
                long limit,
                long & count);

  int svc (void);

  /// signals the internal condition
  void signal (void);

  /// stops the thread by signaling the condition
  void stop (void);

 private:
  /// lock for condition variable
  ACE_Thread_Mutex lock_;

  /// This condition variable is used for signalling changes of the
  /// count
  ACE_Condition <ACE_Thread_Mutex> condition_;

  /// ORB reference
  CORBA::ORB_var orb_;

  /// limit that the count has to reach to provoke a failure
  /// Zero means there is no limit and no failure will occure
  long limit_;

  /// invocation count
  long & count_;

  /// flag that indicates that the thread should be shut down
  bool stop_;
};

#endif /* FAILURE_TASK_H_ */