moveit2
The MoveIt Motion Planning Framework for ROS 2.
Public Types | Public Member Functions | 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.hpp>

Public Types

enum  JobEvent { ADD , REMOVE , COMPLETE }
 Events for jobs. More...
 
typedef std::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...
 
typedef std::function< void()> JobCallback
 The signature for job callbacks. More...
 

Public Member Functions

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

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 56 of file background_processing.hpp.

Member Typedef Documentation

◆ JobCallback

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

The signature for job callbacks.

Definition at line 85 of file background_processing.hpp.

◆ JobUpdateCallback

typedef std::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 82 of file background_processing.hpp.

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 70 of file background_processing.hpp.

Constructor & Destructor Documentation

◆ BackgroundProcessing() [1/2]

moveit::tools::BackgroundProcessing::BackgroundProcessing ( const BackgroundProcessing )
delete

BackgroundProcessing cannot be copy-constructed.

◆ BackgroundProcessing() [2/2]

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

Constructor. The background thread is activated automatically.

Definition at line 46 of file background_processing.cpp.

◆ ~BackgroundProcessing()

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

Finishes currently executing job, clears the remaining queue.

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

Here is the caller graph for this function:

◆ clear()

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

Clear the queue of jobs.

Definition at line 111 of file background_processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearJobUpdateEvent()

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

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

Definition at line 140 of file background_processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getJobCount()

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

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

Definition at line 128 of file background_processing.cpp.

Here is the caller graph for this function:

◆ operator=()

BackgroundProcessing& moveit::tools::BackgroundProcessing::operator= ( const BackgroundProcessing )
delete

BackgroundProcessing cannot be copy-assigned.

◆ setJobUpdateEvent()

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

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

Definition at line 134 of file background_processing.cpp.

Here is the caller graph for this function:

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