Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
nodelet::detail::CallbackQueueManager Class Reference

Internal use. More...

#include <callback_queue_manager.h>


struct  QueueInfo
struct  ThreadInfo

Public Member Functions

void addQueue (const CallbackQueuePtr &queue, bool threaded)
void callbackAdded (const CallbackQueuePtr &queue)
 CallbackQueueManager (uint32_t num_worker_threads=0)
 Constructor. More...
uint32_t getNumWorkerThreads ()
void removeQueue (const CallbackQueuePtr &queue)
void stop ()
 ~CallbackQueueManager ()

Private Types

typedef boost::unordered_map< CallbackQueue *, QueueInfoPtrM_Queue
typedef boost::shared_ptr< QueueInfoQueueInfoPtr
typedef std::vector< CallbackQueuePtrV_Queue
typedef boost::scoped_array< ThreadInfoV_ThreadInfo

Private Member Functions

ThreadInfogetSmallestQueue ()
void managerThread ()
void workerThread (ThreadInfo *)

Private Attributes

uint32_t num_worker_threads_
M_Queue queues_
boost::mutex queues_mutex_
bool running_
boost::thread_group tg_
V_ThreadInfo thread_info_
V_Queue waiting_
boost::condition_variable waiting_cond_
boost::mutex waiting_mutex_

Detailed Description

Internal use.

Manages a set of callback queues, potentially calling callbacks from them concurrently in different threads. Essentially a task manager specialized for callback queues.

Uses 1 manager thread + N worker threads. The manager thread gives work to the worker threads by finding the thread with the fewest pending tasks and appending to that list. This does mean that a single long-running callback can potentially block other callbacks from being executed. Some kind of work-stealing could mitigate this, and is a good direction for future work.

Definition at line 65 of file callback_queue_manager.h.

Member Typedef Documentation

◆ M_Queue

Definition at line 110 of file callback_queue_manager.h.

◆ QueueInfoPtr

Definition at line 108 of file callback_queue_manager.h.

◆ V_Queue

SRMW lockfree queue. waiting_mutex_ has the potential for a lot of contention

Definition at line 115 of file callback_queue_manager.h.

◆ V_ThreadInfo

Use cache-aligned allocator for thread_info_

Definition at line 158 of file callback_queue_manager.h.

Constructor & Destructor Documentation

◆ CallbackQueueManager()

nodelet::detail::CallbackQueueManager::CallbackQueueManager ( uint32_t  num_worker_threads = 0)


By default, uses the number of hardware threads available on the current system.

Definition at line 46 of file callback_queue_manager.cpp.

◆ ~CallbackQueueManager()

nodelet::detail::CallbackQueueManager::~CallbackQueueManager ( )

Definition at line 63 of file callback_queue_manager.cpp.

Member Function Documentation

◆ addQueue()

void nodelet::detail::CallbackQueueManager::addQueue ( const CallbackQueuePtr queue,
bool  threaded 

Definition at line 110 of file callback_queue_manager.cpp.

◆ callbackAdded()

void nodelet::detail::CallbackQueueManager::callbackAdded ( const CallbackQueuePtr queue)

Definition at line 129 of file callback_queue_manager.cpp.

◆ getNumWorkerThreads()

uint32_t nodelet::detail::CallbackQueueManager::getNumWorkerThreads ( )

Definition at line 105 of file callback_queue_manager.cpp.

◆ getSmallestQueue()

CallbackQueueManager::ThreadInfo * nodelet::detail::CallbackQueueManager::getSmallestQueue ( )

Definition at line 139 of file callback_queue_manager.cpp.

◆ managerThread()

void nodelet::detail::CallbackQueueManager::managerThread ( )

Definition at line 163 of file callback_queue_manager.cpp.

◆ removeQueue()

void nodelet::detail::CallbackQueueManager::removeQueue ( const CallbackQueuePtr queue)

Definition at line 121 of file callback_queue_manager.cpp.

◆ stop()

void nodelet::detail::CallbackQueueManager::stop ( )

Definition at line 87 of file callback_queue_manager.cpp.

◆ workerThread()

void nodelet::detail::CallbackQueueManager::workerThread ( ThreadInfo info)

Definition at line 244 of file callback_queue_manager.cpp.

Member Data Documentation

◆ num_worker_threads_

uint32_t nodelet::detail::CallbackQueueManager::num_worker_threads_

Definition at line 162 of file callback_queue_manager.h.

◆ queues_

M_Queue nodelet::detail::CallbackQueueManager::queues_

Definition at line 111 of file callback_queue_manager.h.

◆ queues_mutex_

boost::mutex nodelet::detail::CallbackQueueManager::queues_mutex_

Definition at line 112 of file callback_queue_manager.h.

◆ running_

bool nodelet::detail::CallbackQueueManager::running_

Definition at line 161 of file callback_queue_manager.h.

◆ tg_

boost::thread_group nodelet::detail::CallbackQueueManager::tg_

Definition at line 119 of file callback_queue_manager.h.

◆ thread_info_

V_ThreadInfo nodelet::detail::CallbackQueueManager::thread_info_

Definition at line 159 of file callback_queue_manager.h.

◆ waiting_

V_Queue nodelet::detail::CallbackQueueManager::waiting_

Definition at line 116 of file callback_queue_manager.h.

◆ waiting_cond_

boost::condition_variable nodelet::detail::CallbackQueueManager::waiting_cond_

Definition at line 118 of file callback_queue_manager.h.

◆ waiting_mutex_

boost::mutex nodelet::detail::CallbackQueueManager::waiting_mutex_

Definition at line 117 of file callback_queue_manager.h.

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

Author(s): Tully Foote, Radu Bogdan Rusu
autogenerated on Mon Feb 28 2022 22:57:13