SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Signals | Public Member Functions | Protected Attributes | List of all members
SyncMessenger Class Reference

#include <syncmessenger.h>

Inherits QObject.

+ Collaboration diagram for SyncMessenger:

Signals

void messageSent ()
 

Public Member Functions

 SyncMessenger ()
 
 ~SyncMessenger ()
 
int sendWait (Message &message, unsigned long msPollTime=100)
 Send message and waits for its process completion. More...
 
MessagegetMessage () const
 
void storeMessage (Message &message)
 
void done (int result=0)
 Processing of the message is complete. More...
 

Protected Attributes

QWaitCondition m_waitCondition
 
QMutex m_mutex
 
QAtomicInt m_complete
 
Messagem_message
 
int m_result
 

Detailed Description

This class is responsible of managing the synchronous processing of a message across threads

Definition at line 33 of file syncmessenger.h.

Constructor & Destructor Documentation

◆ SyncMessenger()

SyncMessenger::SyncMessenger ( )

Definition at line 22 of file syncmessenger.cpp.

22  :
23  m_complete(0),
24  m_message(0),
25  m_result(0)
26 {
27  qRegisterMetaType<Message>("Message");
28 }
Message * m_message
Definition: syncmessenger.h:52
QAtomicInt m_complete
Definition: syncmessenger.h:51

◆ ~SyncMessenger()

SyncMessenger::~SyncMessenger ( )

Definition at line 30 of file syncmessenger.cpp.

31 {}

Member Function Documentation

◆ done()

void SyncMessenger::done ( int  result = 0)

Processing of the message is complete.

Definition at line 52 of file syncmessenger.cpp.

References m_complete, m_result, and m_waitCondition.

Referenced by DSPDeviceSinkEngine::handleSynchronousMessages(), DSPDeviceSourceEngine::handleSynchronousMessages(), and DSPDeviceMIMOEngine::handleSynchronousMessages().

53 {
54  m_result = result;
55  m_complete.store(1);
56  m_waitCondition.wakeAll();
57 }
QAtomicInt m_complete
Definition: syncmessenger.h:51
QWaitCondition m_waitCondition
Definition: syncmessenger.h:49
+ Here is the caller graph for this function:

◆ getMessage()

Message* SyncMessenger::getMessage ( ) const
inline

Definition at line 41 of file syncmessenger.h.

Referenced by DSPDeviceSinkEngine::handleSynchronousMessages(), DSPDeviceSourceEngine::handleSynchronousMessages(), and DSPDeviceMIMOEngine::handleSynchronousMessages().

41 { return m_message; }
Message * m_message
Definition: syncmessenger.h:52
+ Here is the caller graph for this function:

◆ messageSent

void SyncMessenger::messageSent ( )
signal

Referenced by sendWait().

+ Here is the caller graph for this function:

◆ sendWait()

int SyncMessenger::sendWait ( Message message,
unsigned long  msPollTime = 100 
)

Send message and waits for its process completion.

Definition at line 33 of file syncmessenger.cpp.

References m_complete, m_message, m_mutex, m_result, m_waitCondition, and messageSent().

Referenced by DSPDeviceMIMOEngine::addAncillarySink(), DSPDeviceMIMOEngine::addChannelSink(), DSPDeviceMIMOEngine::addChannelSource(), DSPDeviceSourceEngine::addSink(), DSPDeviceMIMOEngine::addSinkStream(), DSPDeviceMIMOEngine::addSourceStream(), DSPDeviceSinkEngine::addSpectrumSink(), DSPDeviceMIMOEngine::addSpectrumSink(), DSPDeviceSourceEngine::addThreadedSink(), DSPDeviceSinkEngine::addThreadedSource(), DSPDeviceMIMOEngine::deviceDescription(), DSPDeviceSourceEngine::errorMessage(), DSPDeviceSinkEngine::errorMessage(), DSPDeviceMIMOEngine::errorMessage(), DSPDeviceSourceEngine::initAcquisition(), DSPDeviceSinkEngine::initGeneration(), DSPDeviceMIMOEngine::initProcess(), DSPDeviceMIMOEngine::removeAncillarySink(), DSPDeviceMIMOEngine::removeChannelSink(), DSPDeviceMIMOEngine::removeChannelSource(), DSPDeviceMIMOEngine::removeLastSinkStream(), DSPDeviceMIMOEngine::removeLastSourceStream(), DSPDeviceSourceEngine::removeSink(), DSPDeviceSinkEngine::removeSpectrumSink(), DSPDeviceMIMOEngine::removeSpectrumSink(), DSPDeviceSourceEngine::removeThreadedSink(), DSPDeviceSinkEngine::removeThreadedSource(), DSPDeviceMIMOEngine::setMIMO(), DSPDeviceSinkEngine::setSink(), DSPDeviceSourceEngine::setSource(), DSPDeviceMIMOEngine::setSpectrumSinkInput(), DSPDeviceSinkEngine::sinkDeviceDescription(), DSPDeviceSourceEngine::sourceDeviceDescription(), DSPDeviceSourceEngine::startAcquisition(), DSPDeviceSinkEngine::startGeneration(), and DSPDeviceMIMOEngine::startProcess().

34 {
35  m_message = &message;
36  m_mutex.lock();
37  m_complete.store(0);
38 
39  emit messageSent();
40 
41  while (!m_complete.load())
42  {
43  m_waitCondition.wait(&m_mutex, msPollTime);
44  }
45 
46  int result = m_result;
47  m_mutex.unlock();
48 
49  return result;
50 }
Message * m_message
Definition: syncmessenger.h:52
QAtomicInt m_complete
Definition: syncmessenger.h:51
QWaitCondition m_waitCondition
Definition: syncmessenger.h:49
void messageSent()
+ Here is the caller graph for this function:

◆ storeMessage()

void SyncMessenger::storeMessage ( Message message)
inline

Definition at line 42 of file syncmessenger.h.

Referenced by DSPDeviceSourceEngine::stopAcquistion(), DSPDeviceSinkEngine::stopGeneration(), and DSPDeviceMIMOEngine::stopProcess().

42 { m_message = &message; }
Message * m_message
Definition: syncmessenger.h:52
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_complete

QAtomicInt SyncMessenger::m_complete
protected

Definition at line 51 of file syncmessenger.h.

Referenced by done(), and sendWait().

◆ m_message

Message* SyncMessenger::m_message
protected

Definition at line 52 of file syncmessenger.h.

Referenced by sendWait().

◆ m_mutex

QMutex SyncMessenger::m_mutex
protected

Definition at line 50 of file syncmessenger.h.

Referenced by sendWait().

◆ m_result

int SyncMessenger::m_result
protected

Definition at line 53 of file syncmessenger.h.

Referenced by done(), and sendWait().

◆ m_waitCondition

QWaitCondition SyncMessenger::m_waitCondition
protected

Definition at line 49 of file syncmessenger.h.

Referenced by done(), and sendWait().


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