Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
moveit::tools::BackgroundProcessing Class Reference

This class provides simple API for executing background jobs. A queue of jobs is created and the specified jobs are executed in order, one at a time. More...

#include <background_processing.h>

Inheritance diagram for moveit::tools::BackgroundProcessing:
Inheritance graph
[legend]

Public Types

typedef boost::function< void()> JobCallback
 The signature for job callbacks. More...
 
enum  JobEvent { ADD, REMOVE, COMPLETE }
 Events for jobs. More...
 
typedef boost::function< void(JobEvent, const std::string &)> JobUpdateCallback
 The signature for callback triggered when job events take place: the event that took place and the name of the job. More...
 

Public Member Functions

void addJob (const JobCallback &job, const std::string &name)
 Add a job to the queue of jobs to execute. A name is also specifies for the job. More...
 
 BackgroundProcessing ()
 Constructor. The background thread is activated automatically. More...
 
void clear ()
 Clear the queue of jobs. More...
 
void clearJobUpdateEvent ()
 Clear the callback to be triggered when events in JobEvent take place. More...
 
std::size_t getJobCount () const
 Get the size of the queue of jobs (includes currently processed job). More...
 
void setJobUpdateEvent (const JobUpdateCallback &event)
 Set the callback to be triggered when events in JobEvent take place. More...
 
 ~BackgroundProcessing ()
 Finishes currently executing job, clears the remaining queue. More...
 

Private Member Functions

void processingThread ()
 

Private Attributes

boost::mutex action_lock_
 
std::deque< std::string > action_names_
 
std::deque< JobCallbackactions_
 
boost::condition_variable new_action_condition_
 
bool processing_
 
std::unique_ptr< boost::thread > processing_thread_
 
JobUpdateCallback queue_change_event_
 
bool run_processing_thread_
 

Detailed Description

This class provides simple API for executing background jobs. A queue of jobs is created and the specified jobs are executed in order, one at a time.

Definition at line 120 of file background_processing.h.

Member Typedef Documentation

◆ JobCallback

typedef boost::function<void()> moveit::tools::BackgroundProcessing::JobCallback

The signature for job callbacks.

Definition at line 171 of file background_processing.h.

◆ JobUpdateCallback

typedef boost::function<void(JobEvent, const std::string&)> moveit::tools::BackgroundProcessing::JobUpdateCallback

The signature for callback triggered when job events take place: the event that took place and the name of the job.

Definition at line 168 of file background_processing.h.

Member Enumeration Documentation

◆ JobEvent

Events for jobs.

Enumerator
ADD 

Called when a job is added to the queue.

REMOVE 

Called when a job is removed from the queue without execution.

COMPLETE 

Called when a job is completed (and removed from the queue)

Definition at line 156 of file background_processing.h.

Constructor & Destructor Documentation

◆ BackgroundProcessing()

moveit::tools::BackgroundProcessing::BackgroundProcessing ( )

Constructor. The background thread is activated automatically.

Definition at line 108 of file background_processing.cpp.

◆ ~BackgroundProcessing()

moveit::tools::BackgroundProcessing::~BackgroundProcessing ( )

Finishes currently executing job, clears the remaining queue.

Definition at line 116 of file background_processing.cpp.

Member Function Documentation

◆ addJob()

void moveit::tools::BackgroundProcessing::addJob ( const JobCallback job,
const std::string &  name 
)

Add a job to the queue of jobs to execute. A name is also specifies for the job.

Definition at line 161 of file background_processing.cpp.

◆ clear()

void moveit::tools::BackgroundProcessing::clear ( )

Clear the queue of jobs.

Definition at line 173 of file background_processing.cpp.

◆ clearJobUpdateEvent()

void moveit::tools::BackgroundProcessing::clearJobUpdateEvent ( )

Clear the callback to be triggered when events in JobEvent take place.

Definition at line 200 of file background_processing.cpp.

◆ getJobCount()

std::size_t moveit::tools::BackgroundProcessing::getJobCount ( ) const

Get the size of the queue of jobs (includes currently processed job).

Definition at line 188 of file background_processing.cpp.

◆ processingThread()

void moveit::tools::BackgroundProcessing::processingThread ( )
private

Definition at line 123 of file background_processing.cpp.

◆ setJobUpdateEvent()

void moveit::tools::BackgroundProcessing::setJobUpdateEvent ( const JobUpdateCallback event)

Set the callback to be triggered when events in JobEvent take place.

Definition at line 194 of file background_processing.cpp.

Member Data Documentation

◆ action_lock_

boost::mutex moveit::tools::BackgroundProcessing::action_lock_
mutableprivate

Definition at line 198 of file background_processing.h.

◆ action_names_

std::deque<std::string> moveit::tools::BackgroundProcessing::action_names_
private

Definition at line 201 of file background_processing.h.

◆ actions_

std::deque<JobCallback> moveit::tools::BackgroundProcessing::actions_
private

Definition at line 200 of file background_processing.h.

◆ new_action_condition_

boost::condition_variable moveit::tools::BackgroundProcessing::new_action_condition_
private

Definition at line 199 of file background_processing.h.

◆ processing_

bool moveit::tools::BackgroundProcessing::processing_
private

Definition at line 205 of file background_processing.h.

◆ processing_thread_

std::unique_ptr<boost::thread> moveit::tools::BackgroundProcessing::processing_thread_
private

Definition at line 195 of file background_processing.h.

◆ queue_change_event_

JobUpdateCallback moveit::tools::BackgroundProcessing::queue_change_event_
private

Definition at line 203 of file background_processing.h.

◆ run_processing_thread_

bool moveit::tools::BackgroundProcessing::run_processing_thread_
private

Definition at line 196 of file background_processing.h.


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


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Tue Dec 24 2024 03:27:16