RunningTaskBase Class Reference

#include <ArmarXCore/core/services/tasks/RunningTask.h>

Inherits Thread, and RunningTaskIceBase.

Inherited by RunningTask< LightweightRemoteGuiComponentPluginUser >, RunningTask< SimpleRunningTask< std::function< void(void)> > >, RunningTask< armarx::Observer >, RunningTask< RobotComponents::Component >, RunningTask< armarx::ArVizExample >, RunningTask< armarx::ArVizInteractExample >, RunningTask< armarx::ArVizStorage >, RunningTask< armarx::ArmarXGuiApp >, RunningTask< armarx::ExampleMemoryClient >, RunningTask< armarx::ExternalApplicationManager >, RunningTask< armarx::GamepadUnit >, RunningTask< armarx::GraspProviderExample >, RunningTask< armarx::HapticUnitDynamicSimulation >, RunningTask< armarx::HokuyoLaserScanDevice >, RunningTask< armarx::IceProxyFinderBase >, RunningTask< armarx::KinematicUnitWidgetController >, RunningTask< armarx::LogTableModel >, RunningTask< armarx::MMMSimulation >, RunningTask< armarx::NaturalIKTest >, RunningTask< armarx::ObstacleAvoidingPlatformUnit >, RunningTask< armarx::ObstacleAwarePlatformUnit >, RunningTask< armarx::OpenPoseEstimation >, RunningTask< armarx::OpenPoseEstimationComponentPluginUser >, RunningTask< armarx::OpenPoseSimulation >, RunningTask< armarx::OptoForceUnit >, RunningTask< armarx::OrientedTactileSensorUnit >, RunningTask< armarx::PingLoadTest >, RunningTask< armarx::PointCloudUtility >, RunningTask< armarx::RemoteGui::RemoteGuiBase >, RunningTask< armarx::RobotControl >, RunningTask< armarx::RobotControlUI >, RunningTask< armarx::RobotHealthDummy >, RunningTask< armarx::SceneEditor >, RunningTask< armarx::SimpleStatechartExecutor >, RunningTask< armarx::StatechartExecutorExample >, RunningTask< armarx::StatechartManager >, RunningTask< armarx::TabletopSegmentation >, RunningTask< armarx::ThreadViewer >, RunningTask< armarx::TopicRecorderComponent >, RunningTask< armarx::TopicReplayer >, RunningTask< armarx::TopicTimingServer >, RunningTask< armarx::ViconMarkerProvider >, RunningTask< armarx::WeissHapticSensor >, RunningTask< armarx::XsensIMU >, RunningTask< armarx::armem::server::grasp::GraspMemory >, RunningTask< armarx::localization_and_mapping::cartographer_adapter::ArVizDrawerMapBuilder >, RunningTask< armarx::localization_and_mapping::cartographer_adapter::MessageQueue >, RunningTask< armarx::localization_and_mapping::components::cartographer_localization_and_mapping::LocalizationRemoteGui >, RunningTask< armarx::localization_and_mapping::components::cartographer_localization_and_mapping::MappingRemoteGui >, RunningTask< armarx::memory_to_debug_observer::Component >, RunningTask< armarx::navigation::components::adaptive_distance_to_obstacle_costmap_provider::Component >, RunningTask< armarx::navigation::components::costmap_example::Component >, RunningTask< armarx::navigation::components::distance_to_obstacle_costmap_provider::Component >, RunningTask< armarx::navigation::components::dynamic_distance_to_obstacle_costmap_provider::Component >, RunningTask< armarx::navigation::components::handover_costmap_provider::Component >, RunningTask< armarx::navigation::components::navigation_evaluator::Component >, RunningTask< armarx::navigation::components::orientation_aware_costmap3d_provider::Component >, RunningTask< armarx::navigation::components::room_editor::Component >, RunningTask< memoryx::ProfilerStorage >, RunningTask< visionx::AzureKinectPointCloudProvider >, RunningTask< visionx::CapturingImageProvider >, RunningTask< visionx::CapturingPointCloudProvider >, RunningTask< visionx::ImageProvider >, RunningTask< visionx::NerianVisionImageProvider >, RunningTask< visionx::NerianVisionPointCloudProvider >, RunningTask< visionx::NuitrackPointCloudProvider >, RunningTask< visionx::PointCloudProcessor >, RunningTask< visionx::PointCloudVisualizationHandler >, RunningTask< visionx::opstress::Component >, RunningTask< visionx::yolo::Component >, and RunningTask< T >.

Classes

struct  Impl
 

Public Types

using CallbackT = std::function<void()>
 

Public Member Functions

std::string getName () const
 
bool isFinished () const
 Retrieve finished state of the thread.
 
bool isRunning () const
 Retrieve running state of the thread.
 
bool isStopped ()
 Retrieve whether stop() has been called.
 
void join ()
 Wait for the RunningTask to finish without telling it to finish.
 
 RunningTaskBase (std::string const &name)
 
template<typename T>
 RunningTaskBase (T *parent, void(T::*runningFn)(), const std::string &name="")
 Constructs a running task within the class parent which calls the runningFn in a new thread.
 
void setName (const std::string &name)
 
void setThreadList (ThreadListPtr threadList)
 
void start ()
 Starts the thread.
 
void stop (bool waitForJoin=true)
 Stops the thread.
 
bool waitForFinished (int timeoutMS=-1)
 wait blocking for thread to be finished.
 
void waitForStop ()
 Wait blocking for thread until stop() has been called.
 
 ~RunningTaskBase () override
 Destructor stops the thread and waits for completion.
 

Public Attributes

CallbackT callback
 

Member Typedef Documentation

◆ CallbackT

using CallbackT = std::function<void()>

Constructor & Destructor Documentation

◆ RunningTaskBase() [1/2]

RunningTaskBase ( std::string const & name)

◆ RunningTaskBase() [2/2]

template<typename T>
RunningTaskBase ( T * parent,
void(T::* runningFn )(),
const std::string & name = "" )
inline

Constructs a running task within the class parent which calls the runningFn in a new thread.

Parameters
nameof this thread, that describes what it is doing. If string is empty, it will use the name of the class with RTTI

◆ ~RunningTaskBase()

~RunningTaskBase ( )
override

Destructor stops the thread and waits for completion.

Member Function Documentation

◆ getName()

std::string getName ( ) const

◆ isFinished()

bool isFinished ( ) const

Retrieve finished state of the thread.

The task is finished once the thread has joined.

Returns
finished state

◆ isRunning()

bool isRunning ( ) const

Retrieve running state of the thread.

The task is running when it is started until the thread method joints.

Returns
running state

◆ isStopped()

bool isStopped ( )

Retrieve whether stop() has been called.

Has to be handled in thread function implementation for proper exit.

Returns
stopped state

◆ join()

void join ( )

Wait for the RunningTask to finish without telling it to finish.

◆ setName()

void setName ( const std::string & name)

◆ setThreadList()

void setThreadList ( ThreadListPtr threadList)

◆ start()

void start ( )

Starts the thread.

Only has effect if the task has not been started. After completion of the task, it cannot be started again.

◆ stop()

void stop ( bool waitForJoin = true)

Stops the thread.

Only has effect if the task has been started.

Parameters
waitForJoinwait for the thread to terminate and join with the process.

◆ waitForFinished()

bool waitForFinished ( int timeoutMS = -1)

wait blocking for thread to be finished.

The task is finished once the thread has joined.

Parameters
timeoutMStimeout in milliseconds. If -1 there is no timeout.
Returns
returns true if the task finished in the given time interval

◆ waitForStop()

void waitForStop ( )

Wait blocking for thread until stop() has been called.

Can be used for blocking wait for stop in thread function implementation

Member Data Documentation

◆ callback

CallbackT callback

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