summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_Dispatching.h
blob: 0fecaa31896a77c633934e9f67ceebb7df96eff9 (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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Real-time Event Channel
//
// = FILENAME
//   EC_Dispatching
//
// = AUTHOR
//   Carlos O'Ryan (coryan@cs.wustl.edu)
//
// = DESCRIPTION
//   The dispatching strategies.
//   The EC may be configured with different dispatching strategies,
//   for instance, it can use a pool of threads to dispatch the
//   events, or a set of queues with threads at different priorities
//   for each queue or can simply push the event to the consumer in
//   FIFO order.
//
// = CREDITS
//   Based on previous work by Tim Harrison (harrison@cs.wustl.edu)
//   and other members of the DOC group.
//   More details can be found in:
//   http://www.cs.wustl.edu/~schmidt/oopsla.ps.gz
//   http://www.cs.wustl.edu/~schmidt/JSAC-98.ps.gz
//
//
// ============================================================================

#ifndef TAO_EC_FILTER_H
#define TAO_EC_FILTER_H

#include "orbsvcs/RtecEventComm.h"

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

class TAO_EC_Dispatching
{
  // = TITLE
  //   Abstract base class for the dispatching strategies.
  //
  // = DESCRIPTION
  //   Defines the dispatching strategy interface.
  //
public:
  virtual ~TAO_EC_Dispatching (void);
  // destructor...

  virtual void activate (void) = 0;
  // Initialize all the data structures, activate any internal threads,
  // etc. 

  virtual void shutdown (void) = 0;
  // Deactivate any internal threads and cleanup internal data
  // structures, it should only return once the threads have finished
  // their jobs.

  virtual void push (TAO_EC_ProxyPushSupplier* proxy,
                     const RtecEventComm::EventSet& event,
                     const TAO_EC_QOS_Info& qos_info,
                     CORBA::Environment& env) = 0;
  // The consumer represented by <proxy> should receive <event>.
  // It can use the information in <qos_info> to determine the event
  // priority (among other things).
};

// ****************************************************************

class TAO_EC_Reactive_Dispatching
{
  // = TITLE
  //   Dispatch using the caller thread.
  //
  // = DESCRIPTION
  //   The events are dispatched in FIFO ordering, using the invoking
  //   thread to push the event to the consumer.
  //
public:
  TAO_EC_Priority_Dispatching (RtecScheduler::Scheduler_ptr
                               scheduler);
  // The scheduler is used to find the range of priorities and similar
  // info.

  // = The EC_Dispatching methods.
  virtual void activate (void);
  virtual void shutdown (void);
  virtual void push (TAO_EC_ProxyPushSupplier* proxy,
                     const RtecEventComm::EventSet& event,
                     const TAO_EC_QOS_Info& qos_info,
                     CORBA::Environment& env);
  // @@ proxy->consumer ()->push (event, env);

};

// ****************************************************************

#if 0
#include "orbsvcs/RtecSchedulerC.h"
// @@ Move to a separate file, otherwise we have to include the file
// above everywhere
class TAO_EC_Priority_Dispatching
{
  // = TITLE
  //   Priority based dispatching.
  //
  // = DESCRIPTION
  //   The events are processed using a different queue for each
  //   priority; a thread process each queue, each thread runs at a
  //   different OS priority.
  //
public:
  TAO_EC_Priority_Dispatching (RtecScheduler::Scheduler_ptr
                               scheduler);
  // The scheduler is used to find the range of priorities and similar
  // info.

  // = The EC_Dispatching methods.
  virtual void activate (void);
  virtual void shutdown (void);
  virtual void push (TAO_EC_ProxyPushSupplier* proxy,
                     const RtecEventComm::EventSet& event,
                     const TAO_EC_QOS_Info& qos_info,
                     CORBA::Environment& env);

private:
  ACE_Thread_Manager thread_manager_;
  // Use our own thread manager.
};
#endif /* 0 */

// @@ TODO
// We could implement other dispatching strategies, such as:
// - A single queue with a thread pool to process each event (how does
//   it compare to a thread pool in the ORB?): it should improve
//   throughput when multiple CPUs are present.
// - Enqueuing, but ordering the queue by priority.

#if defined (__ACE_INLINE__)
#include "EC_Dispatching.i"
#endif /* __ACE_INLINE__ */

#endif /* TAO_EC_DISPATCHING_H */