Use the Leader/Follower loop to wait for one specific event in the invocation path. More...
#include <LF_CH_Event.h>
Public Member Functions | |
TAO_LF_CH_Event (void) | |
Constructor. | |
virtual | ~TAO_LF_CH_Event (void) |
Destructor. | |
Private Types | |
typedef ACE_Hash_Map_Manager_Ex < TAO_LF_Follower *, int, ACE_Hash< void * > , ACE_Equal_To < TAO_LF_Follower * > , TAO_SYNCH_MUTEX > | HASH_MAP |
Private Member Functions | |
virtual void | state_changed_i (int new_state) |
Validate and change the state. | |
virtual void | set_state (int new_state) |
Set the state irrespective of anything. | |
virtual int | bind (TAO_LF_Follower *follower) |
Bind a follower. | |
virtual int | unbind (TAO_LF_Follower *follower) |
Unbind the follower. | |
void | validate_state_change (int new_state) |
Private Attributes | |
int | prev_state_ |
The previous state that the LF_CH_Event was in. | |
HASH_MAP | followers_ |
Friends | |
class | TAO_LF_Multi_Event |
| |
int | successful (void) const |
int | error_detected (void) const |
virtual int | is_state_final (void) |
Check whether we have reached the final state.. |
Use the Leader/Follower loop to wait for one specific event in the invocation path.
Concrete event types and manipulation class which is used for connection handling purposes.
Definition at line 41 of file LF_CH_Event.h.
typedef ACE_Hash_Map_Manager_Ex<TAO_LF_Follower *, int, ACE_Hash<void *>, ACE_Equal_To<TAO_LF_Follower *>, TAO_SYNCH_MUTEX> TAO_LF_CH_Event::HASH_MAP [private] |
Definition at line 128 of file LF_CH_Event.h.
TAO_LF_CH_Event::TAO_LF_CH_Event | ( | void | ) |
Constructor.
Definition at line 13 of file LF_CH_Event.cpp.
: TAO_LF_Event (), prev_state_ (TAO_LF_Event::LFS_IDLE) { }
TAO_LF_CH_Event::~TAO_LF_CH_Event | ( | void | ) | [virtual] |
int TAO_LF_CH_Event::bind | ( | TAO_LF_Follower * | follower | ) | [private, 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.
Reimplemented from TAO_LF_Event.
Definition at line 25 of file LF_CH_Event.cpp.
{ return this->followers_.bind (follower, 0); }
int TAO_LF_CH_Event::error_detected | ( | void | ) | const [virtual] |
Return 1 if an error was detected while waiting for the event
Implements TAO_LF_Event.
Definition at line 126 of file LF_CH_Event.cpp.
{ if (this->prev_state_ == TAO_LF_Event::LFS_CONNECTION_WAIT) return this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED; return this->state_ == TAO_LF_Event::LFS_TIMEOUT; }
int TAO_LF_CH_Event::is_state_final | ( | void | ) | [protected, virtual] |
Check whether we have reached the final state..
Implements TAO_LF_Event.
Definition at line 158 of file LF_CH_Event.cpp.
{ return this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED; }
void TAO_LF_CH_Event::set_state | ( | int | new_state | ) | [private, virtual] |
Set the state irrespective of anything.
Reimplemented from TAO_LF_Event.
Definition at line 135 of file LF_CH_Event.cpp.
{ // @@ NOTE: Is this still required? if (this->is_state_final () == 0 && new_state == TAO_LF_Event::LFS_TIMEOUT) { this->state_ = new_state; if (TAO_debug_level > 9) { size_t id = 0; TAO_Connection_Handler *ch = 0; if ((ch = dynamic_cast<TAO_Connection_Handler *> (this)) && ch->transport ()) { id = ch->transport ()->id (); } ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - TAO_LF_CH_Event[%d]::set_state, " "state_ is LFS_TIMEOUT\n", id)); } } }
void TAO_LF_CH_Event::state_changed_i | ( | int | new_state | ) | [private, virtual] |
Validate and change the state.
Implements TAO_LF_Event.
Definition at line 37 of file LF_CH_Event.cpp.
{ if (this->state_ != new_state) { this->validate_state_change (new_state); if (TAO_debug_level > 9) { size_t id = 0; TAO_Connection_Handler *ch = 0; if ((ch = dynamic_cast<TAO_Connection_Handler *> (this)) && ch->transport ()) { id = ch->transport ()->id (); } ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - TAO_LF_CH_Event[%d]::" "state_changed_i, state %C->%C\n", id, TAO_LF_Event::state_name(prev_state_), TAO_LF_Event::state_name(state_))); } } ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->followers_.mutex ())); HASH_MAP::iterator end_it = this->followers_.end (); for (HASH_MAP::iterator it = this->followers_.begin (); it != end_it ; ++it) { it->ext_id_->signal (); } }
int TAO_LF_CH_Event::successful | ( | void | ) | const [virtual] |
Return 1 if the condition was satisfied successfully, 0 if it has not
Implements TAO_LF_Event.
Definition at line 117 of file LF_CH_Event.cpp.
{ if (this->prev_state_ == TAO_LF_Event::LFS_CONNECTION_WAIT) return this->state_ == TAO_LF_Event::LFS_SUCCESS; return this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED; }
int TAO_LF_CH_Event::unbind | ( | TAO_LF_Follower * | follower | ) | [private, virtual] |
Unbind the follower.
Reimplemented from TAO_LF_Event.
Definition at line 31 of file LF_CH_Event.cpp.
{ return this->followers_.unbind (follower); }
void TAO_LF_CH_Event::validate_state_change | ( | int | new_state | ) | [private] |
Definition at line 71 of file LF_CH_Event.cpp.
{ if (this->state_ == TAO_LF_Event::LFS_IDLE) { // From the LFS_IDLE state we can only become active. if (new_state == TAO_LF_Event::LFS_CONNECTION_WAIT) { this->prev_state_ = this->state_; this->state_ = new_state; } return; } else if (this->state_ == TAO_LF_Event::LFS_CONNECTION_WAIT) { // Only a few states are possible from CONNECTION_WAIT states if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED || new_state == TAO_LF_Event::LFS_SUCCESS) { this->prev_state_ = this->state_; this->state_ = new_state; } return; } else if (this->state_ == TAO_LF_Event::LFS_SUCCESS) { if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED) { this->prev_state_ = this->state_; this->state_ = new_state; } return; } else if (this->state_ == TAO_LF_Event::LFS_TIMEOUT) { if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED) { // Dont reset the previous state this->state_ = new_state; } } return; }
friend class TAO_LF_Multi_Event [friend] |
The TAO_LF_Multi_Event class is another specialization of TAO_LF_Event, used for aggregating many connection handlers into a single event object.. It requires friendship so that it can check the is_state_final() flag on each of its contained connection handlers.
Definition at line 51 of file LF_CH_Event.h.
HASH_MAP TAO_LF_CH_Event::followers_ [private] |
Definition at line 129 of file LF_CH_Event.h.
int TAO_LF_CH_Event::prev_state_ [private] |
The previous state that the LF_CH_Event was in.
Definition at line 121 of file LF_CH_Event.h.