TAO_LF_Multi_Event Class Reference

Use the Leader/Follower loop to wait for one specific event in the invocation path. More...

#include <LF_Multi_Event.h>

Inheritance diagram for TAO_LF_Multi_Event:

Inheritance graph
[legend]
Collaboration diagram for TAO_LF_Multi_Event:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_LF_Multi_Event (void)
 Constructor.

virtual ~TAO_LF_Multi_Event (void)
 Destructor.

virtual int bind (TAO_LF_Follower *follower)
 propogate the follower to all the events in the collection.

virtual int unbind (void)
 Unbind the follower from all the collected events.

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

TAO_Connection_Handlerwinner (void)
TAO_Transportbase_transport (void)
 Returns the transport associated with the first entry in the collection.

int successful (void) const
int error_detected (void) const

Protected Member Functions

virtual void state_changed_i (int new_state)
 Validate the state change.

virtual int is_state_final (void)
 Check whether we have reached the final state..


Private Attributes

Event_Nodeevents_
TAO_Connection_Handlerwinner_

Detailed Description

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.

Definition at line 39 of file LF_Multi_Event.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_LF_Multi_Event::TAO_LF_Multi_Event void   ) 
 

Constructor.

Definition at line 12 of file LF_Multi_Event.cpp.

00013   : TAO_LF_Event (),
00014     events_ (0),
00015     winner_ (0)
00016 {
00017 }

TAO_LF_Multi_Event::~TAO_LF_Multi_Event void   )  [virtual]
 

Destructor.

Definition at line 19 of file LF_Multi_Event.cpp.

References TAO_LF_Multi_Event::Event_Node::next_.

00020 {
00021   while (this->events_ != 0)
00022     {
00023       Event_Node *n = this->events_->next_;
00024       delete this->events_;
00025       this->events_ = n;
00026     }
00027 }


Member Function Documentation

void TAO_LF_Multi_Event::add_event TAO_Connection_Handler ch  ) 
 

Adds a handler to the collection.

Definition at line 63 of file LF_Multi_Event.cpp.

References ACE_NEW, TAO_LF_Multi_Event::Event_Node::next_, and TAO_LF_Multi_Event::Event_Node::ptr_.

Referenced by TAO_IIOP_Connector::make_connection(), and TAO_IIOP_Connector::make_parallel_connection().

00064 {
00065   Event_Node *node = 0;
00066   ACE_NEW (node, Event_Node);
00067   node->next_ = this->events_;
00068   node->ptr_ = ev;
00069 
00070   this->events_ = node;
00071 }

TAO_Transport * TAO_LF_Multi_Event::base_transport void   ) 
 

Returns the transport associated with the first entry in the collection.

Definition at line 80 of file LF_Multi_Event.cpp.

References TAO_LF_Multi_Event::Event_Node::ptr_, and TAO_Connection_Handler::transport().

Referenced by TAO_Connect_Strategy::poll(), and TAO_Connect_Strategy::wait().

00081 {
00082   return (this->events_ == 0) ? 0 : this->events_->ptr_->transport();
00083 }

int TAO_LF_Multi_Event::bind TAO_LF_Follower follower  )  [virtual]
 

propogate the follower to all the events in the collection.

Reimplemented from TAO_LF_Event.

Definition at line 30 of file LF_Multi_Event.cpp.

References TAO_LF_Event::bind(), TAO_LF_Multi_Event::Event_Node::next_, and TAO_LF_Multi_Event::Event_Node::ptr_.

00031 {
00032   if (this->TAO_LF_Event::bind(follower) == -1)
00033     {
00034       return -1;
00035     }
00036 
00037   for (Event_Node *n = this->events_; n != 0; n = n->next_)
00038     if (n->ptr_->bind(follower) == -1)
00039       {
00040         return -1;
00041       }
00042   return 0;
00043 }

int TAO_LF_Multi_Event::error_detected void   )  const [virtual]
 

Return 1 if an error was detected while waiting for the event - This iterates over the list of events and returns 1 only if all of them return 1 from error_detected.

Implements TAO_LF_Event.

Definition at line 98 of file LF_Multi_Event.cpp.

References TAO_LF_CH_Event::error_detected(), TAO_LF_Multi_Event::Event_Node::next_, and TAO_LF_Multi_Event::Event_Node::ptr_.

00099 {
00100   int result = 1;
00101   for (Event_Node *n = this->events_; n != 0; n = n->next_)
00102     if (n->ptr_->error_detected () == 0)
00103       result = 0;
00104   return result;
00105 }

int TAO_LF_Multi_Event::is_state_final void   )  [protected, virtual]
 

Check whether we have reached the final state..

Implements TAO_LF_Event.

Definition at line 114 of file LF_Multi_Event.cpp.

References TAO_LF_CH_Event::is_state_final(), TAO_LF_Multi_Event::Event_Node::next_, and TAO_LF_Multi_Event::Event_Node::ptr_.

00115 {
00116   int result = 1;
00117   for (Event_Node *n = this->events_; n != 0; n = n->next_)
00118     if (!n->ptr_->is_state_final () == 0)
00119       result = 0;
00120   return result;
00121 }

void TAO_LF_Multi_Event::state_changed_i int  new_state  )  [protected, virtual]
 

Validate the state change.

Implements TAO_LF_Event.

Definition at line 108 of file LF_Multi_Event.cpp.

00109 {
00110   // no-op
00111 }

int TAO_LF_Multi_Event::successful void   )  const [virtual]
 

Return 1 if the condition was satisfied successfully, 0 if it has not - This iterates over the list of attached events and returns 1 if any of them return 1 from successful.

Implements TAO_LF_Event.

Definition at line 86 of file LF_Multi_Event.cpp.

References TAO_LF_Multi_Event::Event_Node::next_, TAO_LF_Multi_Event::Event_Node::ptr_, TAO_LF_CH_Event::successful(), and winner_.

00087 {
00088   for (Event_Node *n = this->events_; n != 0; n = n->next_)
00089     if (n->ptr_->successful() == 1)
00090       {
00091         this->winner_ = n->ptr_;
00092         return 1;
00093       }
00094   return 0;
00095 }

int TAO_LF_Multi_Event::unbind void   )  [virtual]
 

Unbind the follower from all the collected events.

Reimplemented from TAO_LF_Event.

Definition at line 46 of file LF_Multi_Event.cpp.

References TAO_LF_Multi_Event::Event_Node::next_, TAO_LF_Multi_Event::Event_Node::ptr_, and TAO_LF_Event::unbind().

00047 {
00048   if (this->TAO_LF_Event::unbind() == -1)
00049     {
00050       return -1;
00051     }
00052 
00053   for (Event_Node *n = this->events_; n != 0; n = n->next_)
00054     if (n->ptr_->unbind() == -1)
00055       {
00056         return -1;
00057       }
00058   return 0;
00059 }

TAO_Connection_Handler * TAO_LF_Multi_Event::winner void   ) 
 

Returns the connection handler that caused the successful status to be returned.

Definition at line 74 of file LF_Multi_Event.cpp.

References winner_.

Referenced by TAO_Connector::wait_for_connection_completion().

00075 {
00076   return this->winner_;
00077 }


Member Data Documentation

struct Event_Node* TAO_LF_Multi_Event::events_ [private]
 

Definition at line 91 of file LF_Multi_Event.h.

TAO_Connection_Handler* TAO_LF_Multi_Event::winner_ [mutable, private]
 

Definition at line 93 of file LF_Multi_Event.h.

Referenced by successful(), and winner().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:22:20 2006 for TAO by doxygen 1.3.6