summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_ProxyPushSupplier_Set_T.h
blob: 6da089b33961d34d46cb5bcfecb4272c3a2fa096 (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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Real-time Event Channel
//
// = FILENAME
//   EC_ProxyPushSupplier_Set_T
//
// = AUTHOR
//   Carlos O'Ryan (coryan@cs.wustl.edu)
//
// = 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_PROXYPUSHSUPPLIER_SET_T_H
#define TAO_EC_PROXYPUSHSUPPLIER_SET_T_H

#include "EC_ProxyPushSupplier_Set.h"

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

template<class ACE_LOCK>
class TAO_EC_ProxyPushSupplier_Set_Immediate : public TAO_EC_ProxyPushSupplier_Set
{
  // = TITLE
  //   ProxyPushSupplier_Set_Immediate
  //
  // = DESCRIPTION
  //   A concrete implementation of EC_ProxyPushSupplier_Set that
  //   propagate changes to the set immediately.
  //
  // = LOCKING
  //   Uses parametric types to provide locking.
  //
  // = TODO
  //
public:
  TAO_EC_ProxyPushSupplier_Set_Immediate (void);
  // Constructor.

  // = Read the descriptions in EC_ProxyPushSupplier_Set
  virtual int busy (void);
  virtual int idle (void);
  virtual void connected (TAO_EC_ProxyPushSupplier*,
                          CORBA::Environment&);
  virtual void disconnected (TAO_EC_ProxyPushSupplier*,
                             CORBA::Environment&);
  virtual void shutdown (CORBA::Environment&);

private:
  ACE_LOCK lock_;
  // The lock.
};

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

template<ACE_SYNCH_DECL>
class TAO_EC_ProxyPushSupplier_Set_Delayed : public TAO_EC_ProxyPushSupplier_Set
{
  // = TITLE
  //   ProxyPushSupplier_Set_Delayed
  //
  // = DESCRIPTION
  //   A concrete implementation of EC_ProxyPushSupplier_Set that
  //   delays changes to the set until no threads are using the set.
  //
  // = LOCKING
  //   Uses parametric types to provide locking.
  //
  // = TODO
  //
public:
  TAO_EC_ProxyPushSupplier_Set_Delayed (void);
  // Constructor.

  // = Read the descriptions in EC_ProxyPushSupplier_Set
  virtual int busy (void);
  virtual int idle (void);
  virtual void connected (TAO_EC_ProxyPushSupplier*,
                          CORBA::Environment&);
  virtual void disconnected (TAO_EC_ProxyPushSupplier*,
                             CORBA::Environment&);
  virtual void shutdown (CORBA::Environment&);

protected:
  virtual void execute_delayed_operations (void);

private:
  ACE_SYNCH_MUTEX_T lock_;
  // The lock.

  ACE_SYNCH_CONDITION_T busy_cond_;
  // A condition variable to wait while the object is too busy.

  CORBA::ULong busy_count_;
  // Keep track of the number of threads using the set

  CORBA::ULong write_delay_;
  // Keep track of the number of threads that have used the set since
  // the last change was posted.

  ACE_Unbounded_Queue<ACE_Command_Base*> command_queue_;
  // The commands that carry the delayed operations are enqueued
  // here.
};

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

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "EC_ProxyPushSupplier_Set_T.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("EC_ProxyPushSupplier_Set_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#endif /* TAO_EC_PROXYPUSHSUPPLIER_SET_H */