summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/FaultTolerance/FLARe/RTCORBA/ClientServer/Worker_i.h
blob: 36d8b709565385ab5d944997967cc413290dff80 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef WORKER_I_H_
#define WORKER_I_H_

#include "WorkerS.h"
#include "ace/Task.h"
#include "ace/Condition_T.h"
#include "ace/High_Res_Timer.h"
#include "orbsvcs/orbsvcs/LWFT/StateSynchronizationAgentC.h"

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

  int svc (void);

  void signal (void);

  void stop (void);

 private:
  ACE_Thread_Mutex lock_;
  ACE_Condition <ACE_Thread_Mutex> condition_;
  CORBA::ORB_var orb_;
  long limit_;
  long & count_;
  bool stop_;
};

class Worker_i : public POA_DeCoRAM::Worker
{
 public:
  Worker_i (CORBA::ORB_ptr orb,
            PortableServer::POA_ptr poa,
            const std::string & object_id,
	    StateSynchronizationAgent_ptr agent,
	    long invocations);

  virtual void run_task (CORBA::Double execution_time,
                         bool ignore);

  virtual void set_state (const CORBA::Any & state_value);

  virtual CORBA::Any *get_state ();

  virtual void stop (void);

  virtual StateSynchronizationAgent_ptr agent (void);

  virtual void agent (StateSynchronizationAgent_ptr agent);

  virtual char * object_id (void);
  
  virtual void object_id (const char * object_id);

 private:
  CORBA::ORB_var orb_;

  PortableServer::POA_var poa_;

  std::string object_id_;

  StateSynchronizationAgent_var agent_;

  CORBA::Double load_;
  
  long state_;

  long suicidal_count_;

  Failure_Task task_;

  ACE_High_Res_Timer timer_;
  
  ACE_Time_Value last_execution_time_;
};

#endif /* WORKER_I_H_ */