diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-08-01 23:39:57 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-08-01 23:39:57 +0000 |
commit | 2c3ab374267eb89c1a64bf6c28d6a34137e96b13 (patch) | |
tree | e11d110b2f6e69f07a780756276cc735be3e8fa9 /TAO/tao/LF_Event.cpp | |
parent | 78f15e9fef70e8500baf261258da62677e2340ff (diff) | |
download | ATCD-2c3ab374267eb89c1a64bf6c28d6a34137e96b13.tar.gz |
ChangeLogTag:Wed Aug 1 16:05:36 2001 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'TAO/tao/LF_Event.cpp')
-rw-r--r-- | TAO/tao/LF_Event.cpp | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/TAO/tao/LF_Event.cpp b/TAO/tao/LF_Event.cpp new file mode 100644 index 00000000000..3b03c0b59ad --- /dev/null +++ b/TAO/tao/LF_Event.cpp @@ -0,0 +1,104 @@ +// -*- C++ -*- +// $Id$ + +#include "tao/LF_Event.h" +#include "tao/LF_Follower.h" +#include "tao/Leader_Follower.h" + +#if !defined (__ACE_INLINE__) +# include "tao/LF_Event.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(tao, LF_Event, "$Id$") + +TAO_LF_Event::TAO_LF_Event (void) + : state_ (TAO_LF_Event::LFS_IDLE) + , follower_ (0) +{ +} + +TAO_LF_Event::~TAO_LF_Event (void) +{ +} + +void +TAO_LF_Event::state_changed (int new_state) +{ + if (this->follower_ == 0) + { + this->state_changed_i (new_state); + } + else + { + TAO_Leader_Follower &leader_follower = + this->follower_->leader_follower (); + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, leader_follower.lock ()); + + this->state_changed_i (new_state); + + this->follower_->signal (); + } +} + +void +TAO_LF_Event::state_changed_i (int new_state) +{ + if (this->state_ == new_state) + return; + + // Validate the state change + 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_ACTIVE + || new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED) + this->state_ = new_state; + return; + } + else if (this->state_ == TAO_LF_Event::LFS_ACTIVE) + { + // From LFS_ACTIVE we can only move to a few states + if (new_state != TAO_LF_Event::LFS_IDLE) + { + if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED) + { + this->state_ = TAO_LF_Event::LFS_FAILURE; + } + else + { + this->state_ = new_state; + } + } + return; + } + else if (this->state_ == TAO_LF_Event::LFS_SUCCESS + || this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED) + { + // From the two states above we can go back to ACTIVE, as when a + // request is restarted. + if (new_state == TAO_LF_Event::LFS_ACTIVE) + { + this->state_ = new_state; + } + return; + } + else /* if (this->state_ == TAO_LF_Event::LFS_TIMEOUT || FAILURE ) */ + { + // Other states are final... + } +} + +int +TAO_LF_Event::successful (void) const +{ + return this->state_ == TAO_LF_Event::LFS_SUCCESS; +} + +int +TAO_LF_Event::error_detected (void) const +{ + return (this->state_ == TAO_LF_Event::LFS_FAILURE + || this->state_ == TAO_LF_Event::LFS_TIMEOUT + || this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED); +} |