#include <RemoveAssociationSweeper.h>
Classes | |
class | CancelCommand |
class | CommandBase |
class | ScheduleCommand |
Public Member Functions | |
RemoveAssociationSweeper (ACE_Reactor *reactor, ACE_thread_t owner, T *reader) | |
void | schedule_timer (OpenDDS::DCPS::RcHandle< OpenDDS::DCPS::WriterInfo > &info, bool callback) |
void | cancel_timer (OpenDDS::DCPS::RcHandle< OpenDDS::DCPS::WriterInfo > &info) |
int | handle_timeout (const ACE_Time_Value ¤t_time, const void *arg) |
virtual bool | reactor_is_shut_down () const |
int | remove_info (WriterInfo *const info) |
Private Member Functions | |
~RemoveAssociationSweeper () | |
OPENDDS_VECTOR (RcHandle< WriterInfo >) info_set_ | |
Private Attributes | |
WeakRcHandle< T > | reader_ |
Friends | |
class | CancelCommand |
Definition at line 30 of file RemoveAssociationSweeper.h.
OpenDDS::DCPS::RemoveAssociationSweeper< T >::RemoveAssociationSweeper | ( | ACE_Reactor * | reactor, | |
ACE_thread_t | owner, | |||
T * | reader | |||
) | [inline] |
Definition at line 91 of file RemoveAssociationSweeper.h.
00094 : ReactorInterceptor (reactor, owner) 00095 , reader_(*reader) 00096 { }
OpenDDS::DCPS::RemoveAssociationSweeper< T >::~RemoveAssociationSweeper | ( | ) | [inline, private] |
Definition at line 99 of file RemoveAssociationSweeper.h.
void OpenDDS::DCPS::RemoveAssociationSweeper< T >::cancel_timer | ( | OpenDDS::DCPS::RcHandle< OpenDDS::DCPS::WriterInfo > & | info | ) | [inline] |
Definition at line 118 of file RemoveAssociationSweeper.h.
References c, OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue(), and ACE_Time_Value::zero.
00119 { 00120 info->scheduled_for_removal_ = false; 00121 info->removal_deadline_ = ACE_Time_Value::zero; 00122 CancelCommand c(this, info); 00123 execute_or_enqueue(c); 00124 }
int OpenDDS::DCPS::RemoveAssociationSweeper< T >::handle_timeout | ( | const ACE_Time_Value & | current_time, | |
const void * | arg | |||
) | [inline, virtual] |
Reimplemented from ACE_Event_Handler.
Definition at line 146 of file RemoveAssociationSweeper.h.
References OpenDDS::DCPS::DCPS_debug_level, LM_INFO, OpenDDS::DCPS::ReactorInterceptor::mutex_, OpenDDS::DCPS::WriterInfo::NO_TIMER, OPENDDS_STRING, OpenDDS::DCPS::RemoveAssociationSweeper< T >::reader_, OpenDDS::DCPS::WriterInfo::remove_association_timer_, OpenDDS::DCPS::RemoveAssociationSweeper< T >::remove_info(), and OpenDDS::DCPS::WriterInfo::writer_id_.
00149 { 00150 WriterInfo* const info = 00151 const_cast<WriterInfo*>(reinterpret_cast<const WriterInfo*>(arg)); 00152 00153 { 00154 // info may be destroyed at this moment, we can only access it 00155 // if it is in the info_set_. This could happen when cancel_timer() handle it first. 00156 ACE_Guard<ACE_Thread_Mutex> guard(this->mutex_); 00157 if (this->remove_info(info) == -1) 00158 return 0; 00159 } 00160 00161 info->remove_association_timer_ = WriterInfo::NO_TIMER; 00162 const PublicationId pub_id = info->writer_id_; 00163 00164 RcHandle<T> reader = reader_.lock(); 00165 if (!reader) 00166 return 0; 00167 00168 if (DCPS_debug_level >= 1) { 00169 GuidConverter sub_repo(reader->get_repo_id()); 00170 GuidConverter pub_repo(pub_id); 00171 ACE_DEBUG((LM_INFO, "((%P|%t)) RemoveAssociationSweeper::handle_timeout reader: %C waiting on writer: %C\n", 00172 OPENDDS_STRING(sub_repo).c_str(), 00173 OPENDDS_STRING(pub_repo).c_str())); 00174 } 00175 00176 reader->remove_publication(pub_id); 00177 return 0; 00178 }
OpenDDS::DCPS::RemoveAssociationSweeper< T >::OPENDDS_VECTOR | ( | RcHandle< WriterInfo > | ) | [private] |
Referenced by OpenDDS::DCPS::RemoveAssociationSweeper< T >::remove_info().
virtual bool OpenDDS::DCPS::RemoveAssociationSweeper< T >::reactor_is_shut_down | ( | ) | const [inline, virtual] |
Implements OpenDDS::DCPS::ReactorInterceptor.
Definition at line 42 of file RemoveAssociationSweeper.h.
00043 { 00044 return TheServiceParticipant->is_shut_down(); 00045 }
int OpenDDS::DCPS::RemoveAssociationSweeper< T >::remove_info | ( | WriterInfo *const | info | ) | [inline] |
Definition at line 127 of file RemoveAssociationSweeper.h.
References OpenDDS::DCPS::RemoveAssociationSweeper< T >::OPENDDS_VECTOR(), and OpenDDS::DCPS::swap().
Referenced by OpenDDS::DCPS::RemoveAssociationSweeper< T >::handle_timeout().
00128 { 00129 OPENDDS_VECTOR(RcHandle<WriterInfo>)::iterator itr, last = --info_set_.end(); 00130 // find the RcHandle holds the pointer info in this->info_set_ 00131 // and then swap the found element with the last element in the 00132 // info_set_ vector so we can delete it. 00133 for (itr = info_set_.begin(); itr != info_set_.end(); ++itr){ 00134 if (itr->in() == info) { 00135 if (itr != last) { 00136 std::swap(*itr, info_set_.back()); 00137 } 00138 info_set_.pop_back(); 00139 return 0; 00140 } 00141 } 00142 return -1; 00143 }
void OpenDDS::DCPS::RemoveAssociationSweeper< T >::schedule_timer | ( | OpenDDS::DCPS::RcHandle< OpenDDS::DCPS::WriterInfo > & | info, | |
bool | callback | |||
) | [inline] |
Definition at line 103 of file RemoveAssociationSweeper.h.
References c, OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue(), and ACE_OS::gettimeofday().
00104 { 00105 info->scheduled_for_removal_ = true; 00106 info->notify_lost_ = callback; 00107 ACE_Time_Value time_to_deadline(info->activity_wait_period()); 00108 00109 if (time_to_deadline > ACE_Time_Value(10)) 00110 time_to_deadline = ACE_Time_Value(10); 00111 00112 info->removal_deadline_ = ACE_OS::gettimeofday() + time_to_deadline; 00113 ScheduleCommand c(this, info); 00114 execute_or_enqueue(c); 00115 }
friend class CancelCommand [friend] |
Definition at line 87 of file RemoveAssociationSweeper.h.
WeakRcHandle<T> OpenDDS::DCPS::RemoveAssociationSweeper< T >::reader_ [private] |
Definition at line 53 of file RemoveAssociationSweeper.h.
Referenced by OpenDDS::DCPS::RemoveAssociationSweeper< T >::handle_timeout().