Public Types | Public Member Functions | Private Member Functions | Private Attributes
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>

List of all members.

Public Types

typedef boost::function< void()> JobCallback
 The signature for job callbacks.
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.

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.
 BackgroundProcessing ()
 Constructor. The background thread is activated automatically.
void clear ()
 Clear the queue of jobs.
void clearJobUpdateEvent ()
 Clear the callback to be triggered when events in JobEvent take place.
std::size_t getJobCount () const
 Get the size of the queue of jobs (includes currently processed job).
void setJobUpdateEvent (const JobUpdateCallback &event)
 Set the callback to be triggered when events in JobEvent take place.
 ~BackgroundProcessing ()
 Finishes currently executing job, clears the remaining queue.

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_
boost::scoped_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

Constructor. The background thread is activated automatically.

Definition at line 40 of file background_processing.cpp.

Finishes currently executing job, clears the remaining queue.

Definition at line 48 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 96 of file background_processing.cpp.

Clear the queue of jobs.

Definition at line 108 of file background_processing.cpp.

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

Definition at line 135 of file background_processing.cpp.

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

Definition at line 123 of file background_processing.cpp.

Definition at line 55 of file background_processing.cpp.

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

Definition at line 129 of file background_processing.cpp.


Member Data Documentation

boost::mutex moveit::tools::BackgroundProcessing::action_lock_ [mutable, private]

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.

Definition at line 105 of file background_processing.h.

Definition at line 104 of file background_processing.h.

Definition at line 110 of file background_processing.h.

boost::scoped_ptr<boost::thread> moveit::tools::BackgroundProcessing::processing_thread_ [private]

Definition at line 100 of file background_processing.h.

Definition at line 108 of file background_processing.h.

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 Wed Jun 19 2019 19:23:50