ConditionImpl.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
00009 #include "ConditionImpl.h"
00010 
00011 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00012 
00013 namespace OpenDDS {
00014 namespace DCPS {
00015 
00016 void ConditionImpl::signal_all()
00017 {
00018   if (DCPS_debug_level > 9) {
00019     ACE_DEBUG((LM_DEBUG,
00020                ACE_TEXT("(%P|%t) ConditionImpl::signal_all()\n")));
00021   }
00022 
00023   if (!get_trigger_value()) return;
00024 
00025   WaitSetSet local_ws;
00026   {
00027     ACE_GUARD(ACE_Recursive_Thread_Mutex, g, lock_);
00028     local_ws = waitsets_;
00029   }
00030 
00031   if (DCPS_debug_level > 9) {
00032     ACE_DEBUG((LM_DEBUG,
00033                ACE_TEXT("(%P|%t) ConditionImpl::signal_all() - ")
00034                ACE_TEXT("number of sets: %d, locally: %d.\n"),
00035                this->waitsets_.size(),
00036                local_ws.size()));
00037   }
00038 
00039   for (WaitSetSet::iterator it = local_ws.begin(), end = local_ws.end();
00040        it != end; ++it) {
00041     RcHandle<DDS::WaitSet> ws ((*it).lock());
00042     if (ws)
00043       ws->signal(this);
00044   }
00045 }
00046 
00047 DDS::ReturnCode_t ConditionImpl::attach_to_ws(DDS::WaitSet_ptr ws)
00048 {
00049   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, g, lock_,
00050                    DDS::RETCODE_OUT_OF_RESOURCES);
00051   return waitsets_.insert(OpenDDS::DCPS::WeakRcHandle<DDS::WaitSet>(*ws)).second
00052          ? DDS::RETCODE_OK : DDS::RETCODE_PRECONDITION_NOT_MET;
00053 }
00054 
00055 DDS::ReturnCode_t ConditionImpl::detach_from_ws(DDS::WaitSet_ptr ws)
00056 {
00057   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, g, lock_,
00058                    DDS::RETCODE_OUT_OF_RESOURCES);
00059   return waitsets_.erase(OpenDDS::DCPS::WeakRcHandle<DDS::WaitSet>(*ws))
00060          ? DDS::RETCODE_OK : DDS::RETCODE_PRECONDITION_NOT_MET;
00061 }
00062 
00063 } // namespace DCPS
00064 } // namespace OpenDDS
00065 
00066 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1