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

[legend]
Collaboration diagram for TAO_LF_Event:

[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_SUCCESS, LFS_FAILURE, LFS_TIMEOUT, LFS_CONNECTION_CLOSED }
void | state_changed (int new_state)
| Change the state.
int | successful (void) const
| Return 1 if the condition was satisfied successfully, 0 if it has not.
int | error_detected (void) const
| Return 1 if an error was detected while waiting for the event.
## Public Methods
| TAO_LF_Event (void)
| Constructor.
virtual | ~TAO_LF_Event (void)
| Destructor.
int | bind (TAO_LF_Follower *follower)
| Bind a follower. More...
int | unbind (void)
| Unbind the follower.
int | keep_waiting (void)
| Check if we should keep waiting.
void | reset_state (int new_state)
| Reset the state, irrespective of the previous states.
## Protected Methods
void | state_changed_i (int new_state)
| Validate the state change.
## Private Methods
int | is_state_final (void)
| Check whether we have reached the final state..
void | set_state (int new_state)
| Set the state.
## Private Attributes
int | state_
| The current state.
TAO_LF_Follower* | follower_
| The bound follower thread.
## 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.
  LFS_ACTIVE | The event is active, can change to any of the following states, each of them is 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 )`[inline]`

| Constructor.

TAO_LF_Event::~TAO_LF_Event ( | void )`[virtual]`

| Destructor.

## Member Function Documentation

ACE_INLINE int TAO_LF_Event::bind ( | TAO_LF_Follower * follower )

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

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:

- LF_Event.h
- LF_Event.cpp
- LF_Event.inl