OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Private Types | Private Attributes | List of all members
OpenDDS::Federator::UpdateReceiver< DataType > Class Template Reference

#include <UpdateReceiver_T.h>

Inheritance diagram for OpenDDS::Federator::UpdateReceiver< DataType >:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::Federator::UpdateReceiver< DataType >:
Collaboration graph
[legend]

Public Member Functions

 UpdateReceiver (UpdateProcessor< DataType > &processor)
 Construct with a processor reference. More...
 
virtual ~UpdateReceiver ()
 
virtual int open (void *)
 
virtual int svc ()
 
virtual int close (u_long flags=0)
 
void add (OpenDDS::DCPS::unique_ptr< DataType > sample, OpenDDS::DCPS::unique_ptr< DDS::SampleInfo > info)
 Sample enqueueing. More...
 
void stop ()
 Synchronous termination. More...
 
- Public Member Functions inherited from ACE_Task_Base
 ACE_Task_Base (ACE_Thread_Manager *=0)
 
virtual ~ACE_Task_Base (void)
 
virtual int module_closed (void)
 
virtual int put (ACE_Message_Block *, ACE_Time_Value *=0)
 
virtual int activate (long flags=THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, int n_threads=1, int force_active=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, int grp_id=-1, ACE_Task_Base *task=0, ACE_hthread_t thread_handles[]=0, void *stack[]=0, size_t stack_size[]=0, ACE_thread_t thread_ids[]=0, const char *thr_name[]=0)
 
virtual int wait (void)
 
virtual int suspend (void)
 
virtual int resume (void)
 
int grp_id (void) const
 
void grp_id (int)
 
ACE_Thread_Managerthr_mgr (void) const
 
void thr_mgr (ACE_Thread_Manager *)
 
int is_reader (void) const
 
int is_writer (void) const
 
size_t thr_count (void) const
 
ACE_thread_t last_thread (void) const
 
- Public Member Functions inherited from ACE_Service_Object
 ACE_Service_Object (ACE_Reactor *=0)
 
virtual ~ACE_Service_Object (void)
 
- Public Member Functions inherited from ACE_Event_Handler
virtual ~ACE_Event_Handler (void)
 
virtual ACE_HANDLE get_handle (void) const
 
virtual void set_handle (ACE_HANDLE)
 
virtual int priority (void) const
 
virtual void priority (int priority)
 
virtual int handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_timeout (const ACE_Time_Value &current_time, const void *act=0)
 
virtual int handle_exit (ACE_Process *)
 
virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask)
 
virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)
 
virtual int resume_handler (void)
 
virtual int handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual int handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual void reactor (ACE_Reactor *reactor)
 
virtual ACE_Reactorreactor (void) const
 
virtual ACE_Reactor_Timer_Interfacereactor_timer_interface (void) const
 
virtual Reference_Count add_reference (void)
 
virtual Reference_Count remove_reference (void)
 
Reference_Counting_Policyreference_counting_policy (void)
 
- Public Member Functions inherited from ACE_Shared_Object
 ACE_Shared_Object (void)
 
virtual ~ACE_Shared_Object (void)
 
virtual int init (int argc, ACE_TCHAR *argv[])
 
virtual int fini (void)
 
virtual int info (ACE_TCHAR **info_string, size_t length=0) const
 

Private Types

typedef std::pair< DataType *, DDS::SampleInfo *> DataInfo
 Contents of the queue. More...
 

Private Attributes

UpdateProcessor< DataType > & processor_
 The object that we delegate update processing to. More...
 
bool stop_
 Termination flag. More...
 
ACE_SYNCH_MUTEX lock_
 Protect queue modifications. More...
 
ACE_Condition< ACE_SYNCH_MUTEXworkAvailable_
 Work to do indicator. More...
 
std::list< DataInfoqueue_
 Queue of publication data to process. More...
 

Additional Inherited Members

- Public Types inherited from ACE_Event_Handler
typedef long Reference_Count
 
- Static Public Member Functions inherited from ACE_Task_Base
static ACE_THR_FUNC_RETURN svc_run (void *)
 
static void cleanup (void *object, void *params)
 
- Static Public Member Functions inherited from ACE_Event_Handler
static ACE_THR_FUNC_RETURN read_adapter (void *event_handler)
 
static int register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED)
 
static int remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr)
 
- Public Attributes inherited from ACE_Service_Object
 ACE_ALLOC_HOOK_DECLARE
 
- Public Attributes inherited from ACE_Event_Handler
 LO_PRIORITY
 
 HI_PRIORITY
 
 NULL_MASK
 
 READ_MASK
 
 WRITE_MASK
 
 EXCEPT_MASK
 
 ACCEPT_MASK
 
 CONNECT_MASK
 
 TIMER_MASK
 
 QOS_MASK
 
 GROUP_QOS_MASK
 
 SIGNAL_MASK
 
 ALL_EVENTS_MASK
 
 RWE_MASK
 
 DONT_CALL
 
 ACE_EVENT_HANDLER_NOT_RESUMED
 
 ACE_REACTOR_RESUMES_HANDLER
 
 ACE_APPLICATION_RESUMES_HANDLER
 
- Protected Types inherited from ACE_Event_Handler
typedef ACE_Atomic_Op< ACE_SYNCH_MUTEX, Reference_CountAtomic_Reference_Count
 
- Protected Member Functions inherited from ACE_Event_Handler
 ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY)
 
- Protected Attributes inherited from ACE_Task_Base
size_t thr_count_
 
ACE_Thread_Managerthr_mgr_
 
u_long flags_
 
int grp_id_
 
ACE_thread_t last_thread_id_
 
- Protected Attributes inherited from ACE_Event_Handler
Atomic_Reference_Count reference_count_
 

Detailed Description

template<class DataType>
class OpenDDS::Federator::UpdateReceiver< DataType >

Definition at line 35 of file UpdateReceiver_T.h.

Member Typedef Documentation

◆ DataInfo

template<class DataType>
typedef std::pair<DataType*, DDS::SampleInfo* > OpenDDS::Federator::UpdateReceiver< DataType >::DataInfo
private

Contents of the queue.

Definition at line 76 of file UpdateReceiver_T.h.

Constructor & Destructor Documentation

◆ UpdateReceiver()

template<class DataType>
OpenDDS::Federator::UpdateReceiver< DataType >::UpdateReceiver ( UpdateProcessor< DataType > &  processor)

Construct with a processor reference.

Definition at line 26 of file UpdateReceiver_T.cpp.

27  : processor_(processor),
28  stop_(false),
29  workAvailable_(this->lock_)
30 {
32  ACE_DEBUG((LM_DEBUG,
33  ACE_TEXT("(%P|%t) UpdateReceiver::UpdateReceiver()\n")));
34  }
35 
36  // Always execute the thread.
37  this->open(0);
38 }
#define ACE_DEBUG(X)
UpdateProcessor< DataType > & processor_
The object that we delegate update processing to.
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_Condition< ACE_SYNCH_MUTEX > workAvailable_
Work to do indicator.
ACE_SYNCH_MUTEX lock_
Protect queue modifications.

◆ ~UpdateReceiver()

template<class DataType >
OpenDDS::Federator::UpdateReceiver< DataType >::~UpdateReceiver ( )
virtual

Definition at line 41 of file UpdateReceiver_T.cpp.

42 {
44  ACE_DEBUG((LM_DEBUG,
45  ACE_TEXT("(%P|%t) UpdateReceiver::~UpdateReceiver()\n")));
46  }
47 
48  // Cleanly terminate.
49  this->stop();
50  this->wait();
51 }
#define ACE_DEBUG(X)
void stop()
Synchronous termination.
virtual int wait(void)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30

Member Function Documentation

◆ add()

template<class DataType>
void OpenDDS::Federator::UpdateReceiver< DataType >::add ( OpenDDS::DCPS::unique_ptr< DataType >  sample,
OpenDDS::DCPS::unique_ptr< DDS::SampleInfo info 
)

Sample enqueueing.

Parameters
sample- pointer to the received sample to be processed
info- pointer to the info about the sample to be processed.

NOTE: We take ownership of this data and delete it when we are done processing it.

Definition at line 103 of file UpdateReceiver_T.cpp.

104 {
106  ACE_DEBUG((LM_DEBUG,
107  ACE_TEXT("(%P|%t) UpdateReceiver::add()\n")));
108  }
109 
110  if (this->stop_)
111  return;
112 
113  { // Protect the queue.
114  ACE_GUARD(ACE_SYNCH_MUTEX, guard, this->lock_);
115  this->queue_.push_back(DataInfo(sample.release(), info.release()));
116 
118  ACE_DEBUG((LM_DEBUG,
119  ACE_TEXT("(%P|%t) UpdateReceiver::add() - ")
120  ACE_TEXT(" %d samples waiting to process in 0x%x.\n"),
121  this->queue_.size(),
122  (void*)this));
123  }
124  }
125 
126  this->workAvailable_.signal();
127 }
#define ACE_DEBUG(X)
#define ACE_GUARD(MUTEX, OBJ, LOCK)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
std::list< DataInfo > queue_
Queue of publication data to process.
std::pair< DataType *, DDS::SampleInfo *> DataInfo
Contents of the queue.
ACE_Condition< ACE_SYNCH_MUTEX > workAvailable_
Work to do indicator.
ACE_SYNCH_MUTEX lock_
Protect queue modifications.
int signal(void)

◆ close()

template<class DataType >
int OpenDDS::Federator::UpdateReceiver< DataType >::close ( u_long  flags = 0)
virtual

Reimplemented from ACE_Task_Base.

Definition at line 68 of file UpdateReceiver_T.cpp.

69 {
71  ACE_DEBUG((LM_DEBUG,
72  ACE_TEXT("(%P|%t) UpdateReceiver::close()\n")));
73  }
74 
75  while (this->queue_.size()) {
76  delete this->queue_.front().first;
77  delete this->queue_.front().second;
78  this->queue_.pop_front();
79  }
80 
81  return 0;
82 }
#define ACE_DEBUG(X)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
std::list< DataInfo > queue_
Queue of publication data to process.

◆ open()

template<class DataType >
int OpenDDS::Federator::UpdateReceiver< DataType >::open ( void *  )
virtual

Reimplemented from ACE_Task_Base.

Definition at line 55 of file UpdateReceiver_T.cpp.

56 {
58  ACE_DEBUG((LM_DEBUG,
59  ACE_TEXT("(%P|%t) UpdateReceiver::open()\n")));
60  }
61 
62  // Run as a separate thread.
63  return this->activate();
64 }
#define ACE_DEBUG(X)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
virtual int activate(long flags=THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, int n_threads=1, int force_active=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, int grp_id=-1, ACE_Task_Base *task=0, ACE_hthread_t thread_handles[]=0, void *stack[]=0, size_t stack_size[]=0, ACE_thread_t thread_ids[]=0, const char *thr_name[]=0)

◆ stop()

template<class DataType >
void OpenDDS::Federator::UpdateReceiver< DataType >::stop ( void  )

Synchronous termination.

Definition at line 86 of file UpdateReceiver_T.cpp.

87 {
89  ACE_DEBUG((LM_DEBUG,
90  ACE_TEXT("(%P|%t) UpdateReceiver::stop()\n")));
91  }
92 
93  // Indicate the thread should stop and get its attention.
94  if (this->stop_)
95  return;
96 
97  this->stop_ = true;
98  this->workAvailable_.signal();
99 }
#define ACE_DEBUG(X)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_Condition< ACE_SYNCH_MUTEX > workAvailable_
Work to do indicator.
int signal(void)

◆ svc()

template<class DataType >
int OpenDDS::Federator::UpdateReceiver< DataType >::svc ( void  )
virtual

Reimplemented from ACE_Task_Base.

Definition at line 131 of file UpdateReceiver_T.cpp.

132 {
134  ACE_DEBUG((LM_DEBUG,
135  ACE_TEXT("(%P|%t) UpdateReceiver::svc()\n")));
136  }
137 
138  // Continue until we are synchronously terminated.
139  while (this->stop_ == false) {
140  { // Block until there is work to do.
141  ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, this->lock_, 0);
142 
143  while (this->queue_.size() == 0) {
144  // This releases the lock while we block.
145  this->workAvailable_.wait();
146 
148  ACE_DEBUG((LM_DEBUG,
149  ACE_TEXT("(%P|%t) UpdateReceiver::svc() - ")
150  ACE_TEXT("wakeup in 0x%x.\n"),
151  (void*)this));
152  }
153 
154  // We were asked to stop instead.
155  if (this->stop_ == true) {
157  ACE_DEBUG((LM_DEBUG,
158  ACE_TEXT("(%P|%t) UpdateReceiver::svc() - ")
159  ACE_TEXT("discontinuing processing after wakeup in 0x%x.\n"),
160  (void*)this));
161  }
162 
163  return 0;
164  }
165  }
166  }
167 
169  ACE_DEBUG((LM_DEBUG,
170  ACE_TEXT("(%P|%t) UpdateReceiver::svc() - ")
171  ACE_TEXT("processing a sample in 0x%x.\n"),
172  (void*)this));
173  }
174 
175  // Delegate actual processing to the publication manager.
176  this->processor_.processSample(
177  this->queue_.front().first,
178  this->queue_.front().second);
179 
180  { // Remove the completed work.
181  ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, this->lock_, 0);
182  delete this->queue_.front().first;
183  delete this->queue_.front().second;
184  this->queue_.pop_front();
185  }
186  }
187 
189  ACE_DEBUG((LM_DEBUG,
190  ACE_TEXT("(%P|%t) UpdateReceiver::svc() - ")
191  ACE_TEXT("discontinuing processing after sample complete in 0x%x.\n"),
192  (void*)this));
193  }
194 
195  return 0;
196 }
#define ACE_DEBUG(X)
UpdateProcessor< DataType > & processor_
The object that we delegate update processing to.
int wait(const ACE_Time_Value *abstime)
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
std::list< DataInfo > queue_
Queue of publication data to process.
ACE_Condition< ACE_SYNCH_MUTEX > workAvailable_
Work to do indicator.
ACE_SYNCH_MUTEX lock_
Protect queue modifications.

Member Data Documentation

◆ lock_

template<class DataType>
ACE_SYNCH_MUTEX OpenDDS::Federator::UpdateReceiver< DataType >::lock_
private

Protect queue modifications.

Definition at line 70 of file UpdateReceiver_T.h.

◆ processor_

template<class DataType>
UpdateProcessor<DataType>& OpenDDS::Federator::UpdateReceiver< DataType >::processor_
private

The object that we delegate update processing to.

Definition at line 64 of file UpdateReceiver_T.h.

◆ queue_

template<class DataType>
std::list<DataInfo> OpenDDS::Federator::UpdateReceiver< DataType >::queue_
private

Queue of publication data to process.

Definition at line 79 of file UpdateReceiver_T.h.

◆ stop_

template<class DataType>
bool OpenDDS::Federator::UpdateReceiver< DataType >::stop_
private

Termination flag.

Definition at line 67 of file UpdateReceiver_T.h.

◆ workAvailable_

template<class DataType>
ACE_Condition<ACE_SYNCH_MUTEX> OpenDDS::Federator::UpdateReceiver< DataType >::workAvailable_
private

Work to do indicator.

Definition at line 73 of file UpdateReceiver_T.h.


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