SignalLogger
A library for signal logging.
any_node::ThreadedPublisher< MessageType > Class Template Reference

#include <ThreadedPublisher.hpp>

Public Member Functions

 ThreadedPublisher (const ros::Publisher &publisher, unsigned int maxMessageBufferSize=10, bool autoPublishRos=true)
 
virtual ~ThreadedPublisher ()
 
void publish (const boost::shared_ptr< MessageType > &message)
 
void publish (const MessageType &message)
 
void shutdown ()
 
std::string getTopic () const
 
uint32_t getNumSubscribers () const
 
bool isLatched () const
 
void sendRos ()
 

Protected Member Functions

void addMessageToBuffer (const MessageType &message)
 
void notifyThread ()
 
void threadedPublish ()
 

Protected Attributes

std::mutex publisherMutex_
 
ros::Publisher publisher_
 
std::mutex messageBufferMutex_
 
std::queue< MessageType > messageBuffer_
 
unsigned int maxMessageBufferSize_ = 0
 
bool autoPublishRos_
 
std::thread thread_
 
std::mutex notifyThreadMutex_
 
std::condition_variable notifyThreadCv_
 
std::atomic< bool > notifiedThread_
 
std::atomic< bool > shutdownRequested_
 

Constructor & Destructor Documentation

◆ ThreadedPublisher()

template<typename MessageType >
any_node::ThreadedPublisher< MessageType >::ThreadedPublisher ( const ros::Publisher &  publisher,
unsigned int  maxMessageBufferSize = 10,
bool  autoPublishRos = true 
)
inline

◆ ~ThreadedPublisher()

template<typename MessageType >
virtual any_node::ThreadedPublisher< MessageType >::~ThreadedPublisher ( )
inlinevirtual

Member Function Documentation

◆ addMessageToBuffer()

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::addMessageToBuffer ( const MessageType &  message)
inlineprotected

◆ getNumSubscribers()

template<typename MessageType >
uint32_t any_node::ThreadedPublisher< MessageType >::getNumSubscribers ( ) const
inline

◆ getTopic()

template<typename MessageType >
std::string any_node::ThreadedPublisher< MessageType >::getTopic ( ) const
inline

◆ isLatched()

template<typename MessageType >
bool any_node::ThreadedPublisher< MessageType >::isLatched ( ) const
inline

◆ notifyThread()

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::notifyThread ( )
inlineprotected

◆ publish() [1/2]

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::publish ( const boost::shared_ptr< MessageType > &  message)
inline

◆ publish() [2/2]

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::publish ( const MessageType &  message)
inline

◆ sendRos()

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::sendRos ( )
inline

Send all messages in the buffer.

◆ shutdown()

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::shutdown ( )
inline

◆ threadedPublish()

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::threadedPublish ( )
inlineprotected

Member Data Documentation

◆ autoPublishRos_

template<typename MessageType >
bool any_node::ThreadedPublisher< MessageType >::autoPublishRos_
protected

◆ maxMessageBufferSize_

template<typename MessageType >
unsigned int any_node::ThreadedPublisher< MessageType >::maxMessageBufferSize_ = 0
protected

◆ messageBuffer_

template<typename MessageType >
std::queue<MessageType> any_node::ThreadedPublisher< MessageType >::messageBuffer_
protected

◆ messageBufferMutex_

template<typename MessageType >
std::mutex any_node::ThreadedPublisher< MessageType >::messageBufferMutex_
protected

◆ notifiedThread_

template<typename MessageType >
std::atomic<bool> any_node::ThreadedPublisher< MessageType >::notifiedThread_
protected

◆ notifyThreadCv_

template<typename MessageType >
std::condition_variable any_node::ThreadedPublisher< MessageType >::notifyThreadCv_
protected

◆ notifyThreadMutex_

template<typename MessageType >
std::mutex any_node::ThreadedPublisher< MessageType >::notifyThreadMutex_
protected

◆ publisher_

template<typename MessageType >
ros::Publisher any_node::ThreadedPublisher< MessageType >::publisher_
protected

◆ publisherMutex_

template<typename MessageType >
std::mutex any_node::ThreadedPublisher< MessageType >::publisherMutex_
mutableprotected

◆ shutdownRequested_

template<typename MessageType >
std::atomic<bool> any_node::ThreadedPublisher< MessageType >::shutdownRequested_
protected

◆ thread_

template<typename MessageType >
std::thread any_node::ThreadedPublisher< MessageType >::thread_
protected

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