Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_LF_Event Class Reference

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

#include <LF_Event.h>

Inheritance diagram for TAO_LF_Event:

Inheritance graph
[legend]
Collaboration diagram for TAO_LF_Event:

Collaboration graph
[legend]
List of all members.

State management

A Leader/Followers event goes through several states during its lifetime.

We use an enum to represent those states and state changes are validated according to the rules below.

enum  {
  LFS_IDLE, LFS_ACTIVE, LFS_CONNECTION_WAIT, LFS_SUCCESS,
  LFS_FAILURE, LFS_TIMEOUT, LFS_CONNECTION_CLOSED
}
void state_changed (int new_state)
 Change the state. More...

int successful (void) const
 Return 1 if the condition was satisfied successfully, 0 if it has not. More...

int error_detected (void) const
 Return 1 if an error was detected while waiting for the event. More...


Public Types


Public Methods

 TAO_LF_Event (void)
 Constructor. More...

virtual ~TAO_LF_Event (void)
 Destructor. More...

int bind (TAO_LF_Follower *follower)
 An event can be waited on by at most one follower thread, this method is used to bind the waiting thread to the event, in order to let the event signal any important state changes. More...

int unbind (void)
 Unbind the follower. More...

int keep_waiting (void)
 Check if we should keep waiting. More...

void reset_state (int new_state)
 Reset the state, irrespective of the previous states. More...


Protected Methods

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


Private Methods

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

void set_state (int new_state)
 Set the state. More...


Private Attributes

int state_
 The current state. More...

TAO_LF_Followerfollower_
 The bound follower thread. More...


Friends

class TAO_Leader_Follower

Detailed Description

Use the Leader/Follower loop to wait for one specific event.

The Leader/Follower event loop is used to wait for incoming responses, as well as to wait for all the data to be flushed. This class encapsulates this event loop. It uses Template Method to parametrize the 'waited for' predicate (i.e. reply received or message sent.)

Todo:
Implementing the Leader/Followers loop in this class, as well as the callbacks to communicate that an event has completed leads to excessive coupling. A better design would use a separate class to signal the events, that would allow us to remove the Leader/Followers logic from the ORB. However, that requires other major changes and it somewhat complicates the design.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
LFS_IDLE  The event is created, initial state can only move to LFS_ACTIVE or LFS_CONNECTION_WAIT.
LFS_ACTIVE  The event is active, can change to any of the following states, each of them is a final state.
LFS_CONNECTION_WAIT  The event is waiting for connection completion. It can change to the any of the following states, each of them being a final state.
LFS_SUCCESS  The event has completed successfully.
LFS_FAILURE  A failure has been detected while the event was active.
LFS_TIMEOUT  The event has timed out.
LFS_CONNECTION_CLOSED  The connection was closed while the state was active.


Constructor & Destructor Documentation

TAO_LF_Event::TAO_LF_Event void   
 

Constructor.

TAO_LF_Event::~TAO_LF_Event void    [virtual]
 

Destructor.


Member Function Documentation

ACE_INLINE int TAO_LF_Event::bind TAO_LF_Follower   follower
 

An event can be waited on by at most one follower thread, this method is used to bind the waiting thread to the event, in order to let the event signal any important state changes.

Returns:
-1 if the LF_Event is already bound, 0 otherwise

int TAO_LF_Event::error_detected void    const
 

Return 1 if an error was detected while waiting for the event.

ACE_INLINE int TAO_LF_Event::is_state_final void    [private]
 

Check whether we have reached the final state..

ACE_INLINE int TAO_LF_Event::keep_waiting void   
 

Check if we should keep waiting.

ACE_INLINE void TAO_LF_Event::reset_state int    new_state
 

Reset the state, irrespective of the previous states.

ACE_INLINE void TAO_LF_Event::set_state int    new_state [private]
 

Set the state.

void TAO_LF_Event::state_changed int    new_state
 

Change the state.

void TAO_LF_Event::state_changed_i int    new_state [protected]
 

Validate the state change.

int TAO_LF_Event::successful void    const
 

Return 1 if the condition was satisfied successfully, 0 if it has not.

ACE_INLINE int TAO_LF_Event::unbind void   
 

Unbind the follower.


Friends And Related Function Documentation

friend class TAO_Leader_Follower [friend]
 


Member Data Documentation

TAO_LF_Follower* TAO_LF_Event::follower_ [private]
 

The bound follower thread.

int TAO_LF_Event::state_ [private]
 

The current state.


The documentation for this class was generated from the following files:
Generated on Thu Oct 10 18:40:52 2002 for TAO by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001