ThreadSynch.inl

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 "ThreadSynchResource.h"
00009 #include "EntryExit.h"
00010 
00011 /// Note that we allow the ThreadSynchResource pointer to be NULL to
00012 /// support the NullSynch case.
00013 ACE_INLINE
00014 OpenDDS::DCPS::ThreadSynch::ThreadSynch(ThreadSynchResource* resource)
00015   : worker_(0),
00016     resource_(resource)
00017 {
00018   DBG_ENTRY_LVL("ThreadSynch","ThreadSynch",6);
00019 }
00020 
00021 ACE_INLINE
00022 OpenDDS::DCPS::ThreadSynchWorker*
00023 OpenDDS::DCPS::ThreadSynch::worker()
00024 {
00025   return worker_;
00026 }
00027 
00028 ACE_INLINE int
00029 OpenDDS::DCPS::ThreadSynch::register_worker(ThreadSynchWorker* worker)
00030 {
00031   DBG_ENTRY_LVL("ThreadSynch","register_worker",6);
00032   this->worker_ = worker;
00033   return this->register_worker_i();
00034 }
00035 
00036 ACE_INLINE void
00037 OpenDDS::DCPS::ThreadSynch::unregister_worker()
00038 {
00039   DBG_ENTRY_LVL("ThreadSynch","unregister_worker",6);
00040   this->unregister_worker_i();
00041   this->worker_ = 0;
00042   delete this->resource_;
00043   this->resource_ = 0;
00044 }
00045 
00046 ACE_INLINE OpenDDS::DCPS::ThreadSynchWorker::WorkOutcome
00047 OpenDDS::DCPS::ThreadSynch::perform_work()
00048 {
00049   DBG_ENTRY_LVL("ThreadSynch","perform_work",6);
00050 
00051   if (this->worker_ == 0) {
00052     return ThreadSynchWorker::WORK_OUTCOME_NO_MORE_TO_DO;
00053   }
00054 
00055   return this->worker_->perform_work();
00056 }
00057 
00058 ACE_INLINE int
00059 OpenDDS::DCPS::ThreadSynch::wait_on_clogged_resource()
00060 {
00061   DBG_ENTRY_LVL("ThreadSynch","wait_on_clogged_resource",6);
00062 
00063   int result = -1;
00064 
00065   if (this->resource_) {
00066     result = this->resource_->wait_to_unclog();
00067 
00068   } else {
00069     ACE_ERROR((LM_ERROR,
00070                "(%P|%t) ERROR: ThreadSynch cannot wait on a NULL clogged resource.\n"));
00071   }
00072 
00073   return result;
00074 }
00075 

Generated on Fri Feb 12 20:05:28 2016 for OpenDDS by  doxygen 1.4.7