summaryrefslogtreecommitdiff
path: root/TAO/tao/LF_Multi_Event.h
blob: fa9f836d548ce703f2edcba18edb98fc98f9e7d3 (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file LF_Multi_Event.h
 *
 *  @author Phil Mesnier <mesnier_p@ociweb.com>
 */
//=============================================================================

#ifndef TAO_LF_MULTI_EVENT_H
#define TAO_LF_MULTI_EVENT_H

#include /**/ "ace/pre.h"

#include "tao/LF_Event.h"

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

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

// Forward decls
class TAO_Connection_Handler;
class TAO_Transport;

/**
 * @class TAO_LF_Multi_Event
 *
 * @brief Use the Leader/Follower loop to wait for one specific event
 * in the invocation path.
 *
 * Used by the parallel connection strategy for waiting on one of many
 * connections.
 */
class TAO_Export TAO_LF_Multi_Event: public TAO_LF_Event
{
public:
  /// Constructor
  TAO_LF_Multi_Event ();

  /// Destructor
  virtual ~TAO_LF_Multi_Event ();

  /// Propagate the follower to all the events in the collection.
  virtual int bind (TAO_LF_Follower *follower);

  /// Unbind the follower from all the collected events.
  virtual int unbind (TAO_LF_Follower *follower);

  /// Adds a handler to the collection
  void add_event (TAO_Connection_Handler *ch);

  /// Returns the connection handler that caused the successful status
  /// to be returned.
  TAO_Connection_Handler *winner();

  /// Returns the transport associated with the first entry in the collection.
  TAO_Transport *base_transport();

private:
  void operator= (const TAO_LF_Multi_Event &);
  TAO_LF_Multi_Event (const TAO_LF_Multi_Event &);

protected:
  /// Validate the state change
  virtual void state_changed_i (LFS_STATE new_state);

  /// Check whether we have reached the final state..
  virtual bool is_state_final () const;

  /// Return true if the condition was satisfied successfully, false if it
  /// has not - This iterates over the list of attached events and
  /// returns true if any of them return true from successful.
  virtual bool successful_i () const;

  /// Return true if an error was detected while waiting for the
  /// event - This iterates over the list of events and returns
  /// true only if all of them return true from error_detected().
  virtual bool error_detected_i () const;

private:
  struct Event_Node {
    TAO_Connection_Handler * ptr_;
    Event_Node *next_;
  };

  struct Event_Node *events_;

  mutable TAO_Connection_Handler * winner_;
};

TAO_END_VERSIONED_NAMESPACE_DECL

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

#endif  /* TAO_LF_Multi_EVENT_H */