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 57 of file background_processing.h.

Member Typedef Documentation

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

The signature for job callbacks.

Definition at line 76 of file background_processing.h.

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 73 of file background_processing.h.

Member Enumeration Documentation

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 61 of file background_processing.h.

Constructor & Destructor Documentation

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

Constructor. The background thread is activated automatically.

Definition at line 44 of file background_processing.cpp.

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

Finishes currently executing job, clears the remaining queue.

Definition at line 52 of file background_processing.cpp.

Member Function Documentation

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 97 of file background_processing.cpp.

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

Clear the queue of jobs.

Definition at line 109 of file background_processing.cpp.

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

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

Definition at line 136 of file background_processing.cpp.

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

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

Definition at line 124 of file background_processing.cpp.

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

Definition at line 59 of file background_processing.cpp.

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

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

Definition at line 130 of file background_processing.cpp.

Member Data Documentation

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

Definition at line 103 of file background_processing.h.

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

Definition at line 106 of file background_processing.h.

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

Definition at line 105 of file background_processing.h.

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

Definition at line 104 of file background_processing.h.

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

Definition at line 110 of file background_processing.h.

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

Definition at line 100 of file background_processing.h.

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

Definition at line 108 of file background_processing.h.

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

Definition at line 101 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 Sun Oct 18 2020 13:16:34