nodelet::detail::CallbackQueueManager Class Reference

Internal use. More...

#include <callback_queue_manager.h>

List of all members.


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=boost::thread::hardware_concurrency())
uint32_t getNumWorkerThreads ()
void removeQueue (const CallbackQueuePtr &queue)
void stop ()
 ~CallbackQueueManager ()

Private Types

typedef boost::unordered_map
< CallbackQueue
*, QueueInfoPtr
typedef boost::shared_ptr
< QueueInfo
typedef std::vector
< CallbackQueuePtr
typedef boost::scoped_array
< 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 61 of file callback_queue_manager.h.

Member Typedef Documentation

Definition at line 102 of file callback_queue_manager.h.

typedef boost::shared_ptr<QueueInfo> nodelet::detail::CallbackQueueManager::QueueInfoPtr [private]

Definition at line 100 of file callback_queue_manager.h.

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

Definition at line 107 of file callback_queue_manager.h.

typedef boost::scoped_array<ThreadInfo> nodelet::detail::CallbackQueueManager::V_ThreadInfo [private]
Use cache-aligned allocator for thread_info_

Definition at line 150 of file callback_queue_manager.h.

Constructor & Destructor Documentation

nodelet::detail::CallbackQueueManager::CallbackQueueManager ( uint32_t  num_worker_threads = boost::thread::hardware_concurrency()  ) 

Definition at line 46 of file callback_queue_manager.cpp.

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

Definition at line 60 of file callback_queue_manager.cpp.

Member Function Documentation

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

Definition at line 107 of file callback_queue_manager.cpp.

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

Definition at line 126 of file callback_queue_manager.cpp.

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

Definition at line 102 of file callback_queue_manager.cpp.

CallbackQueueManager::ThreadInfo * nodelet::detail::CallbackQueueManager::getSmallestQueue (  )  [private]

Definition at line 136 of file callback_queue_manager.cpp.

void nodelet::detail::CallbackQueueManager::managerThread (  )  [private]

Definition at line 160 of file callback_queue_manager.cpp.

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

Definition at line 118 of file callback_queue_manager.cpp.

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

Definition at line 84 of file callback_queue_manager.cpp.

void nodelet::detail::CallbackQueueManager::workerThread ( ThreadInfo info  )  [private]

Definition at line 241 of file callback_queue_manager.cpp.

Member Data Documentation

Definition at line 154 of file callback_queue_manager.h.

Definition at line 103 of file callback_queue_manager.h.

Definition at line 104 of file callback_queue_manager.h.

Definition at line 153 of file callback_queue_manager.h.

boost::thread_group nodelet::detail::CallbackQueueManager::tg_ [private]

Definition at line 111 of file callback_queue_manager.h.

Definition at line 151 of file callback_queue_manager.h.

Definition at line 108 of file callback_queue_manager.h.

boost::condition_variable nodelet::detail::CallbackQueueManager::waiting_cond_ [private]

Definition at line 110 of file callback_queue_manager.h.

Definition at line 109 of file callback_queue_manager.h.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines

Author(s): Tully Foote, Radu Bogdan Rusu
autogenerated on Fri Jan 11 11:44:26 2013