OpenDDS::DCPS::ThreadSynch Class Reference

#include <ThreadSynch.h>

Inheritance diagram for OpenDDS::DCPS::ThreadSynch:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::ThreadSynch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~ThreadSynch ()
int register_worker (ThreadSynchWorker &worker)
void unregister_worker ()
 Our owner, the worker_, is breaking our relationship.
virtual void work_available ()=0

Protected Member Functions

 ThreadSynch (ThreadSynchResource *resource)
int wait_on_clogged_resource ()
virtual int register_worker_i ()
virtual void unregister_worker_i ()
WeakRcHandle< ThreadSynchWorkerworker ()
 Access the worker implementation directly.

Private Attributes

WeakRcHandle< ThreadSynchWorkerworker_
unique_ptr< ThreadSynchResourceresource_

Detailed Description

This class is the base class for different ThreadSynch stratege, currently only the thread per connection strategy is implemented and used.

Notes for object ownership: 1) Pointer to TransportSendStrategy object (as ThreadSynchWorker) directly but not reference counted. It won't have access problem during it lifetime because the TransportSendStrategy object owns this ThreadSynch object. 2) The ThreadSynch object is created by the ThreadSynchResource object and it owns the ThreadSynchResource object.

Definition at line 34 of file ThreadSynch.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::ThreadSynch::~ThreadSynch (  )  [virtual]

Definition at line 15 of file ThreadSynch.cpp.

References DBG_ENTRY_LVL.

00016 {
00017   DBG_ENTRY_LVL("ThreadSynch","~ThreadSynch",6);
00018 }

ACE_INLINE OpenDDS::DCPS::ThreadSynch::ThreadSynch ( ThreadSynchResource resource  )  [protected]

Note that we allow the ThreadSynchResource pointer to be NULL to support the NullSynch case.

Definition at line 14 of file ThreadSynch.inl.

References DBG_ENTRY_LVL.

00015   : resource_(resource)
00016 {
00017   DBG_ENTRY_LVL("ThreadSynch","ThreadSynch",6);
00018 }


Member Function Documentation

ACE_INLINE int OpenDDS::DCPS::ThreadSynch::register_worker ( ThreadSynchWorker worker  ) 

The worker must introduce himself to this ThreadSynch object. It is the worker object that "owns" this ThreadSynch object. Returns 0 for success, -1 for failure.

Definition at line 28 of file ThreadSynch.inl.

References DBG_ENTRY_LVL, OpenDDS::DCPS::ThreadSynchWorker::get_handle(), register_worker_i(), resource_, and worker_.

00029 {
00030   DBG_ENTRY_LVL("ThreadSynch","register_worker",6);
00031   this->worker_ = worker;
00032   if (resource_)
00033     resource_->set_handle(worker.get_handle());
00034   return this->register_worker_i();
00035 }

Here is the call graph for this function:

int OpenDDS::DCPS::ThreadSynch::register_worker_i (  )  [protected, virtual]

The default implementation is to do nothing here. The subclass may override the implementation in order to do something when the worker registers. Returns 0 for success, -1 for failure.

Reimplemented in OpenDDS::DCPS::PerConnectionSynch.

Definition at line 21 of file ThreadSynch.cpp.

References DBG_ENTRY_LVL.

Referenced by register_worker().

00022 {
00023   DBG_ENTRY_LVL("ThreadSynch","register_worker_i",6);
00024   // Default implementation is to do nothing here.  Subclass may override.
00025   return 0;
00026 }

Here is the caller graph for this function:

ACE_INLINE void OpenDDS::DCPS::ThreadSynch::unregister_worker (  ) 

Our owner, the worker_, is breaking our relationship.

Definition at line 38 of file ThreadSynch.inl.

References DBG_ENTRY_LVL, and unregister_worker_i().

00039 {
00040   DBG_ENTRY_LVL("ThreadSynch","unregister_worker",6);
00041   this->unregister_worker_i();
00042 }

Here is the call graph for this function:

void OpenDDS::DCPS::ThreadSynch::unregister_worker_i (  )  [protected, virtual]

The default implementation is to do nothing here. The subclass may override the implementation in order to do something when the worker unregisters.

Reimplemented in OpenDDS::DCPS::PerConnectionSynch, and OpenDDS::DCPS::PoolSynch.

Definition at line 29 of file ThreadSynch.cpp.

References DBG_ENTRY_LVL.

Referenced by unregister_worker().

00030 {
00031   DBG_ENTRY_LVL("ThreadSynch","unregister_worker_i",6);
00032   // Default implementation is to do nothing here.  Subclass may override.
00033 }

Here is the caller graph for this function:

ACE_INLINE int OpenDDS::DCPS::ThreadSynch::wait_on_clogged_resource (  )  [protected]

Definition at line 46 of file ThreadSynch.inl.

References DBG_ENTRY_LVL, LM_ERROR, and resource_.

Referenced by OpenDDS::DCPS::PerConnectionSynch::svc().

00047 {
00048   DBG_ENTRY_LVL("ThreadSynch","wait_on_clogged_resource",6);
00049 
00050   int result = -1;
00051 
00052   if (this->resource_) {
00053     result = this->resource_->wait_to_unclog();
00054 
00055   } else {
00056     ACE_ERROR((LM_ERROR,
00057                "(%P|%t) ERROR: ThreadSynch cannot wait on a NULL clogged resource.\n"));
00058   }
00059 
00060   return result;
00061 }

Here is the caller graph for this function:

virtual void OpenDDS::DCPS::ThreadSynch::work_available (  )  [pure virtual]

The ThreadSynchWorker would like to have its perform_work() called from the appropriate thread once the ThreadSynchResource claims that it is_ready_for_work().

Implemented in OpenDDS::DCPS::NullSynch, OpenDDS::DCPS::PerConnectionSynch, OpenDDS::DCPS::PoolSynch, and OpenDDS::DCPS::ReactorSynch.

Referenced by OpenDDS::DCPS::TcpSendStrategy::schedule_output().

Here is the caller graph for this function:

ACE_INLINE OpenDDS::DCPS::WeakRcHandle< OpenDDS::DCPS::ThreadSynchWorker > OpenDDS::DCPS::ThreadSynch::worker (  )  [protected]

Access the worker implementation directly.

Definition at line 22 of file ThreadSynch.inl.

References worker_.

Referenced by OpenDDS::DCPS::ReactorSynch::ReactorSynch(), OpenDDS::DCPS::PerConnectionSynch::svc(), and OpenDDS::DCPS::ReactorSynch::~ReactorSynch().

00023 {
00024   return worker_;
00025 }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 75 of file ThreadSynch.h.

Referenced by register_worker(), and wait_on_clogged_resource().

Definition at line 74 of file ThreadSynch.h.

Referenced by register_worker(), and worker().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1