summaryrefslogtreecommitdiff
path: root/performance-tests/Server_Concurrency/Leader_Follower/RT_CORBA_Leader_Follower.h
blob: 4664bd3cda8b6d533401d9b56c3826be5144553f (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//=============================================================================
/**
 *  @file    RT_CORBA_Leader_Follower.h
 *
 *  $Id$
 *
 *   The leader follower test modified to suit RTCORBA tests. The
 *   original  leader follower test has too many things that doesnt
 *   get what we are looking for (read it as just confusing enough)
 *   . Hence a new test.
 *
 *  @author Balachandran Natarajan <bala@cs.wustl.edu>
 */
//=============================================================================
#ifndef PERF_TEST_RT_CORBA_LEADER_FOLLOWER_H
#define PERF_TEST_RT_CORBA_LEADER_FOLLOWER_H
#include /**/ "ace/pre.h"
#include "ace/Task.h"


#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#if defined (ACE_HAS_THREADS)

#include "ace/Manual_Event.h"

enum DEBUGGING_RANGE
{
  DEBUG_NONE = 0,
  DEBUG
};


/**
 * @class Synchronisers
 *
 * @brief This class provides all the synchrnoisers used in this
 *  test.
 *
 *
 */

/// Forward declaration..
class Leader_Follower_Task;

class Synchronisers
{
public:
  friend class Leader_Follower_Task;

  /// Ctor
  Synchronisers (void);

  int  start_synchronization (void);
  int  end_synchronization (void);

private:

  /// The mutex and condition variable that is used for
  /// synchronisation.
  ACE_SYNCH_MUTEX mutex_;

  ACE_SYNCH_CONDITION condition_;

  /// A manual event
  ACE_Manual_Event event_;
};


/**
 * @class Leader_Follower_Task
 *
 * @brief This class provide the interface and an implementation to
 *  simulate how the LF pattern in the ORB would behave.
 *
 *
 *  Basically all threads ready to do an upcall would wait on a token
 *  or lock. The thread that gets the token before it gets ready to do
 *  the upcall would wake up a thread waiting on the token.
 *
 */

class Leader_Follower_Task : public ACE_Task_Base
{
public:

  /// Ctor with a mutex and a condition variable
  Leader_Follower_Task (Synchronisers &synch);

  /// Messages consumed
  int processed (void);

  /// Method that is run by a daemon thread
  int svc (void);

private:
  /// Number of messages processed by this thread
  int messages_consumed_;

  /// Our reference to the synchroniser
  Synchronisers &synch_;
};

#endif /*ACE_HAS_THREADS*/

#include /**/ "ace/post.h"
#endif /*PERF_TEST_RT_CORBA_LEADER_FOLLOWER*/