TAO 3.1.4
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
TAO_LF_Event Class Referenceabstract

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]

Public Member Functions

 TAO_LF_Event ()
 Constructor.
 
virtual ~TAO_LF_Event ()
 Destructor.
 
virtual int bind (TAO_LF_Follower *follower)
 Bind a follower.
 
virtual int unbind (TAO_LF_Follower *follower)
 Unbind the follower.
 

Friends

class TAO_Leader_Follower
 

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 defined in the concrete classes. We treat the states as finite states in a FSM. The possible sequence of states through which the FSM migrates is defined in the concrete classes.

enum  LFS_STATE {
  LFS_IDLE = 0 , LFS_ACTIVE , LFS_CONNECTION_WAIT , LFS_SUCCESS ,
  LFS_FAILURE , LFS_TIMEOUT , LFS_CONNECTION_CLOSED
}
 The current state. More...
 
LFS_STATE state_
 The current state.
 
TAO_LF_Followerfollower_
 The bounded follower.
 
void state_changed (LFS_STATE new_state, TAO_Leader_Follower &lf)
 
bool successful (TAO_Leader_Follower &lf) const
 
bool error_detected (TAO_Leader_Follower &lf) const
 
bool keep_waiting (TAO_Leader_Follower &lf) const
 Check if we should keep waiting.
 
void reset_state (LFS_STATE new_state)
 Reset the state, irrespective of the previous states.
 
static const char * state_name (LFS_STATE st)
 The current state.
 
virtual void state_changed_i (LFS_STATE new_state)=0
 Validate the state change.
 
bool keep_waiting_i () const
 Check if we should keep waiting.
 
virtual bool successful_i () const =0
 
virtual bool error_detected_i () const =0
 
virtual bool is_state_final () const =0
 Check whether we have reached the final state..
 
virtual void set_state (LFS_STATE new_state)
 Set the state irrespective of anything.
 

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 or connection establishment etc.)

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

◆ LFS_STATE

The current state.

Enumerator
LFS_IDLE 

The event is created, and is in initial state.

LFS_ACTIVE 

The event is active.

LFS_CONNECTION_WAIT 

The event is waiting for connection completion.

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.

Constructor & Destructor Documentation

◆ TAO_LF_Event()

TAO_LF_Event::TAO_LF_Event ( )

Constructor.

◆ ~TAO_LF_Event()

TAO_LF_Event::~TAO_LF_Event ( )
virtual

Destructor.

Member Function Documentation

◆ bind()

int TAO_LF_Event::bind ( TAO_LF_Follower * follower)
virtual

Bind a 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.

This is virtual to allow the LF_Multi_Event derived type share the follower with all the subordinate LF_CH_Events.

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

Reimplemented in TAO_LF_CH_Event, and TAO_LF_Multi_Event.

◆ error_detected()

bool TAO_LF_Event::error_detected ( TAO_Leader_Follower & lf) const

Return true if an error was detected while waiting for the event

◆ error_detected_i()

virtual bool TAO_LF_Event::error_detected_i ( ) const
protectedpure virtual

Return true if an error was detected while waiting for the event

Implemented in TAO_LF_CH_Event, TAO_LF_Invocation_Event, and TAO_LF_Multi_Event.

◆ is_state_final()

virtual bool TAO_LF_Event::is_state_final ( ) const
protectedpure virtual

Check whether we have reached the final state..

Implemented in TAO_LF_CH_Event, TAO_LF_Invocation_Event, and TAO_LF_Multi_Event.

◆ keep_waiting()

bool TAO_LF_Event::keep_waiting ( TAO_Leader_Follower & lf) const

Check if we should keep waiting.

◆ keep_waiting_i()

bool TAO_LF_Event::keep_waiting_i ( ) const
protected

Check if we should keep waiting.

◆ reset_state()

void TAO_LF_Event::reset_state ( LFS_STATE new_state)

Reset the state, irrespective of the previous states.

◆ set_state()

void TAO_LF_Event::set_state ( LFS_STATE new_state)
privatevirtual

Set the state irrespective of anything.

Reimplemented in TAO_LF_CH_Event.

◆ state_changed()

void TAO_LF_Event::state_changed ( LFS_STATE new_state,
TAO_Leader_Follower & lf )

Accessor to change the state. The state isn't changed unless certain conditions are satisfied.

Sort of double-checked optimization..

◆ state_changed_i()

virtual void TAO_LF_Event::state_changed_i ( LFS_STATE new_state)
protectedpure virtual

Validate the state change.

Implemented in TAO_LF_CH_Event, TAO_LF_Invocation_Event, and TAO_LF_Multi_Event.

◆ state_name()

const char * TAO_LF_Event::state_name ( LFS_STATE st)
static

The current state.

◆ successful()

bool TAO_LF_Event::successful ( TAO_Leader_Follower & lf) const

Return true if the condition was satisfied successfully, false if it has not

◆ successful_i()

virtual bool TAO_LF_Event::successful_i ( ) const
protectedpure virtual

Return true if the condition was satisfied successfully, false if it has not

Implemented in TAO_LF_CH_Event, TAO_LF_Invocation_Event, and TAO_LF_Multi_Event.

◆ unbind()

int TAO_LF_Event::unbind ( TAO_LF_Follower * follower)
virtual

Unbind the follower.

Reimplemented in TAO_LF_CH_Event, and TAO_LF_Multi_Event.

Friends And Related Symbol Documentation

◆ TAO_Leader_Follower

friend class TAO_Leader_Follower
friend

Member Data Documentation

◆ follower_

TAO_LF_Follower* TAO_LF_Event::follower_
protected

The bounded follower.

◆ state_

LFS_STATE TAO_LF_Event::state_
protected

The current state.


The documentation for this class was generated from the following files: