OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::ReactorSynch Class Reference

Send thread synchronization utilizing a reactor. More...

#include <ReactorSynch.h>

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

Public Member Functions

 ReactorSynch (ThreadSynchResource *synch_resource, TransportSendStrategy *strategy, ACE_Reactor *reactor)
 
virtual ~ReactorSynch ()
 
virtual void work_available ()
 
- Public Member Functions inherited from OpenDDS::DCPS::ThreadSynch
virtual ~ThreadSynch ()
 
int register_worker (ThreadSynchWorker &worker)
 
void unregister_worker ()
 Our owner, the worker_, is breaking our relationship. More...
 

Private Attributes

ScheduleOutputHandlerscheduleOutputHandler_
 Notification event handler. More...
 
ACE_Event_Handler_var safeHandler_
 Memory management using the provided (kluge) var type. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::ThreadSynch
 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. More...
 

Detailed Description

Send thread synchronization utilizing a reactor.

This class implements sending thread synchronization by scheduling qeueued data sending to be handled by a reactor. The initial implementation will share the TransportReactorTask reactor for all sending threads; which means that all receiving and queued sends will be sharing the same thread. Or thread pool.

Calls to enable and disable sending on queued data by the reactor are scheduled to be enabled and disabled on the reactor by notifying the reactor to make the update. This ensures that no locks will be held (other than the Reactor::token_) when the call into the reactor is made.

References to the containing TransportSendStrategy and the reactor are held as raw pointers since they are guaranteed to be valid for the lifetime of this object (this is held in the same containing object).

Definition at line 39 of file ReactorSynch.h.

Constructor & Destructor Documentation

◆ ReactorSynch()

ACE_INLINE OpenDDS::DCPS::ReactorSynch::ReactorSynch ( ThreadSynchResource synch_resource,
TransportSendStrategy strategy,
ACE_Reactor reactor 
)

Construct with raw pointers from the containing TransportSendStrategy.

Definition at line 12 of file ReactorSynch.inl.

References ACE_DEBUG, ACE_TEXT(), DBG_ENTRY_LVL, OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, safeHandler_, scheduleOutputHandler_, and OpenDDS::DCPS::ThreadSynch::worker().

17  : ThreadSynch(synch_resource),
18  scheduleOutputHandler_( new ScheduleOutputHandler( strategy, reactor))
19 {
20  DBG_ENTRY_LVL("ReactorSynch","ReactorSynch",6);
21 
22  // Manage the handler storage using the provided _var.
24 
25  if (DCPS_debug_level > 4) {
26  std::size_t id = 0;
27  RcHandle<ThreadSynchWorker> worker = this->worker().lock();
28  if( worker) {
29  id = worker->id();
30  }
31  ACE_DEBUG((LM_DEBUG,
32  ACE_TEXT("(%P|%t) ReactorSynch::ReactorSynch() [%d] - ")
33  ACE_TEXT("establishing synch %C a worker.\n"),
34  id,(worker ? "with":"without")));
35  }
36 }
#define ACE_DEBUG(X)
WeakRcHandle< ThreadSynchWorker > worker()
Access the worker implementation directly.
Definition: ThreadSynch.inl:22
ThreadSynch(ThreadSynchResource *resource)
Definition: ThreadSynch.inl:14
ACE_Event_Handler_var safeHandler_
Memory management using the provided (kluge) var type.
Definition: ReactorSynch.h:56
ScheduleOutputHandler * scheduleOutputHandler_
Notification event handler.
Definition: ReactorSynch.h:53
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_TEXT("TCP_Factory")
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68

◆ ~ReactorSynch()

OpenDDS::DCPS::ReactorSynch::~ReactorSynch ( )
virtual

Definition at line 16 of file ReactorSynch.cpp.

References ACE_DEBUG, ACE_TEXT(), DBG_ENTRY_LVL, OpenDDS::DCPS::DCPS_debug_level, LM_DEBUG, scheduleOutputHandler_, and OpenDDS::DCPS::ThreadSynch::worker().

17 {
18  DBG_ENTRY_LVL("ReactorSynch","~ReactorSynch",6);
19 
20  // Release out unmanaged copy of the handler.
21  // The managed copy will perform the actual delete.
23 
24  if (DCPS_debug_level > 4) {
25  std::size_t id = 0;
26  RcHandle<ThreadSynchWorker> worker = this->worker().lock();
27  if( worker) {
28  id = worker->id();
29  }
30  ACE_DEBUG((LM_DEBUG,
31  ACE_TEXT("(%P|%t) ReactorSynch::~ReactorSynch() [%d] - ")
32  ACE_TEXT("dismantling synch %C worker.\n"),
33  id,(worker?"with":"without")));
34  }
35 }
#define ACE_DEBUG(X)
WeakRcHandle< ThreadSynchWorker > worker()
Access the worker implementation directly.
Definition: ThreadSynch.inl:22
ScheduleOutputHandler * scheduleOutputHandler_
Notification event handler.
Definition: ReactorSynch.h:53
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_TEXT("TCP_Factory")
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68

Member Function Documentation

◆ work_available()

void OpenDDS::DCPS::ReactorSynch::work_available ( )
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().

Implements OpenDDS::DCPS::ThreadSynch.

Definition at line 38 of file ReactorSynch.cpp.

References DBG_ENTRY_LVL, OpenDDS::DCPS::ScheduleOutputHandler::schedule_output(), and scheduleOutputHandler_.

39 {
40  DBG_ENTRY_LVL("ReactorSynch","work_available",6);
41 
42  // Schedule queued data to be sent by the reactor.
44 }
ScheduleOutputHandler * scheduleOutputHandler_
Notification event handler.
Definition: ReactorSynch.h:53
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
void schedule_output()
Update output processing in the reactor.

Member Data Documentation

◆ safeHandler_

ACE_Event_Handler_var OpenDDS::DCPS::ReactorSynch::safeHandler_
private

Memory management using the provided (kluge) var type.

Definition at line 56 of file ReactorSynch.h.

Referenced by ReactorSynch().

◆ scheduleOutputHandler_

ScheduleOutputHandler* OpenDDS::DCPS::ReactorSynch::scheduleOutputHandler_
private

Notification event handler.

Definition at line 53 of file ReactorSynch.h.

Referenced by ReactorSynch(), work_available(), and ~ReactorSynch().


The documentation for this class was generated from the following files: