00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009 #include "ConditionImpl.h"
00010
00011 namespace OpenDDS {
00012 namespace DCPS {
00013
00014 void ConditionImpl::signal_all()
00015 {
00016 if (DCPS_debug_level > 9) {
00017 ACE_DEBUG((LM_DEBUG,
00018 ACE_TEXT("(%P|%t) ConditionImpl::signal_all()\n")));
00019 }
00020
00021 if (!get_trigger_value()) return;
00022
00023 WaitSetSet local_ws;
00024 {
00025 ACE_GUARD(ACE_Recursive_Thread_Mutex, g, lock_);
00026 local_ws = waitsets_;
00027 }
00028
00029 if (DCPS_debug_level > 9) {
00030 ACE_DEBUG((LM_DEBUG,
00031 ACE_TEXT("(%P|%t) ConditionImpl::signal_all() - ")
00032 ACE_TEXT("number of sets: %d, locally: %d.\n"),
00033 this->waitsets_.size(),
00034 local_ws.size()));
00035 }
00036
00037 for (WaitSetSet::iterator it = local_ws.begin(), end = local_ws.end();
00038 it != end; ++it) {
00039 (*it)->signal(this);
00040 }
00041 }
00042
00043 DDS::ReturnCode_t ConditionImpl::attach_to_ws(DDS::WaitSet_ptr ws)
00044 {
00045 DDS::WaitSet_var wsv(DDS::WaitSet::_duplicate(ws));
00046 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, g, lock_,
00047 DDS::RETCODE_OUT_OF_RESOURCES);
00048 return waitsets_.insert(wsv).second
00049 ? DDS::RETCODE_OK : DDS::RETCODE_PRECONDITION_NOT_MET;
00050 }
00051
00052 DDS::ReturnCode_t ConditionImpl::detach_from_ws(DDS::WaitSet_ptr ws)
00053 {
00054 DDS::WaitSet_var wsv(DDS::WaitSet::_duplicate(ws));
00055 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, g, lock_,
00056 DDS::RETCODE_OUT_OF_RESOURCES);
00057 return waitsets_.erase(wsv)
00058 ? DDS::RETCODE_OK : DDS::RETCODE_PRECONDITION_NOT_MET;
00059 }
00060
00061 }
00062 }