summaryrefslogtreecommitdiff
path: root/performance-tests/Server_Concurrency/Queue_Based_Workers/RT_CORBA_Workers.h
blob: 46d78e8624c0eca67f40eebdc15c28884f288e84 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* -*- C++ -*- */
//=============================================================================
/**
 *  @file    RT_CORBA_Workers.h
 *
 *  $Id$
 *
 *   The Workes test modified to suit RTCORBA tests. The  original
 *   Workers 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_WORKERS_H
#define PERF_TEST_RT_CORBA_WORKERS_H
#include /**/ "ace/pre.h"

#include "ace/Task_T.h"
#include "ace/Manual_Event.h"

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

#if defined (ACE_HAS_THREADS)

enum DEBUGGING_RANGE
{
  DEBUG_NONE = 0,
  DEBUG
};

typedef ACE_Message_Queue<ACE_MT_SYNCH> Message_Queue;

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

/// Forward declaration..
class IO_Task;
class Worker_Task;

class Synchronisers
{
public:
  friend class IO_Task;
  friend class Worker_Task;

  enum
  {
    /// Used in the message block to stop processing of message
    /// blocks.
    MB_STOP_FLAG = 0x2000
  };

  /// Ctor
  Synchronisers (void);

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

private:

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

  /// A manual event
  ACE_Manual_Event event_;
};


/**************************************************************/
/**
 * @class Input_Task
 *
 * @brief Class that does the Input work ie. puts the events into the
 *  message queue
 */

class Input_Task : public ACE_Task<ACE_MT_SYNCH>
{
public:
  /// Ctor
  Input_Task (Message_Queue *mq,
              Synchronisers &synch);

  /// The thread runs inside this method..
  int svc (void);

private:

  /// Our referance to Synchronisers
  Synchronisers &synch_;
};

/**************************************************************/
/**
 * @class Output_Task
 *
 * @brief Class that does the Output work ie. getsx the events into the
 *  message queue
 */

class Output_Task : public ACE_Task<ACE_MT_SYNCH>
{
public:
  /// Ctor
  Output_Task (Message_Queue *mq,
              Synchronisers &synch);

  /// The thread runs inside this method..
  int svc (void);

  /// Need to overload this method to do anything useful..
  virtual int put (ACE_Message_Block *, ACE_Time_Value * = 0);

private:

  /// Our referance to Synchronisers
  Synchronisers &synch_;
};


/**************************************************************/
/**
 * @class Synchronisers
 *
 * @brief This class provides and interface for all the upcall threads
 *  to run and do the actual work
 */

class Worker_Task : public ACE_Task<ACE_MT_SYNCH>
{
public:
  /// Ctor
  Worker_Task (Message_Queue *mq,
               Synchronisers &synch);

  /// Methods in which the threads run on
  int svc (void);

  /// Processed messages
  int processed (void);
private:

  /// Our referance to Synchronisers
  Synchronisers &synch_;

  /// Number of messages processed by us
  size_t messages_processed_;
};




#endif /*ACE_HAS_THREADS*/

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