summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Reactive_Pulling_Strategy.h
blob: 77cc7c4bad260f909ed5540bcb5f1f20b2a30b3e (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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Cos Event Channel
//
// = FILENAME
//   CEC_Reactive_Pulling_Strategy
//
// = AUTHOR
//   Carlos O'Ryan (coryan@cs.wustl.edu)
//
// = CREDITS
//
// ============================================================================

#ifndef TAO_CEC_REACTIVE_PULLING_STRATEGY_H
#include "ace/pre.h"
#define TAO_CEC_REACTIVE_PULLING_STRATEGY_H

#include "CEC_Pulling_Strategy.h"

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

#include "orbsvcs/Event/EC_Worker.h"
#include "tao/corba.h"

class TAO_CEC_ProxyPullConsumer;
class TAO_CEC_EventChannel;
class TAO_CEC_ConsumerAdmin;
class TAO_CEC_SupplierControl;
class TAO_CEC_Reactive_Pulling_Strategy;

class TAO_ORBSVCS_Export TAO_CEC_Pulling_Strategy_Adapter : public ACE_Event_Handler
{
  // = TITLE
  //   Forwards timeout events to the Reactive Pulling Strategy
  //
  // = DESCRIPTION
  //   The Reactive Pulling Strategy strategy uses the reactor to
  //   periodically wakeup and try top pull events from each
  //   PullSupplier connected to the EventChannel.
  //
public:
  TAO_CEC_Pulling_Strategy_Adapter (TAO_CEC_Reactive_Pulling_Strategy *adaptee);
  // Constructor

  // = Documented in ACE_Event_Handler.
  virtual int handle_timeout (const ACE_Time_Value &tv,
                              const void *arg = 0);

private:
  TAO_CEC_Reactive_Pulling_Strategy *adaptee_;
  // The adapted object
};

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

class TAO_ORBSVCS_Export TAO_CEC_Reactive_Pulling_Strategy : public TAO_CEC_Pulling_Strategy
{
  // = 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_CEC_Reactive_Pulling_Strategy (const ACE_Time_Value &rate,
                                     TAO_CEC_EventChannel *event_channel,
                                     CORBA::ORB_ptr orb);
  // The scheduler is used to find the range of priorities and similar
  // info.

  void handle_timeout (const ACE_Time_Value &tv,
                       const void* arg);
  // Receive the timeout from the adapter

  // = The CEC_Pulling_Strategy methods.
  virtual void activate (void);
  virtual void shutdown (void);

private:
  TAO_CEC_Pulling_Strategy_Adapter adapter_;
  // The Adapter for the reactor events

  ACE_Time_Value rate_;
  // The polling rate

  TAO_CEC_EventChannel *event_channel_;
  // The event channel

  CORBA::ORB_var orb_;
  // The ORB

  CORBA::PolicyCurrent_var policy_current_;
  // To control the timeout policy in the thread

  CORBA::PolicyList policy_list_;
  // Precomputed policy list to the set timeout.

  ACE_Reactor *reactor_;
  // The ORB reactor
};

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

class TAO_CEC_Pull_Event : public TAO_EC_Worker<TAO_CEC_ProxyPullConsumer>
{
public:
  TAO_CEC_Pull_Event (TAO_CEC_ConsumerAdmin *consumer_admin,
                      TAO_CEC_SupplierControl *control);

  virtual void work (TAO_CEC_ProxyPullConsumer *consumer,
                     CORBA::Environment &ACE_TRY_ENV);

private:
  TAO_CEC_ConsumerAdmin *consumer_admin_;
  // Used to propagate the events.

  TAO_CEC_SupplierControl *supplier_control_;
  // To report failed or dead suppliers
};

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

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