YARP  2.3.70
Yet Another Robot Platform
yarp::os::Runnable Class Reference

A class that can be managed by another thread. More...

#include <yarp/os/Runnable.h>

+ Inheritance diagram for yarp::os::Runnable:

Public Member Functions

virtual ~Runnable ()
 Destructor. More...
 
virtual void run ()
 Body to run - could be periodic or continuous. More...
 
virtual void close ()
 User-defined procedure for stopping execution. More...
 
virtual void beforeStart ()
 Should be called from the creator before the thread exists and before a call that requested the thread returns. More...
 
virtual void afterStart (bool success)
 Should be called from the creator after the thread exists and before a call that requested the thread returns. More...
 
virtual bool threadInit ()
 Initialization method. More...
 
virtual void threadRelease ()
 Release method. More...
 

Detailed Description

A class that can be managed by another thread.

Definition at line 21 of file Runnable.h.

Constructor & Destructor Documentation

◆ ~Runnable()

yarp::os::Runnable::~Runnable ( )
virtual

Destructor.

Definition at line 10 of file Runnable.cpp.

Member Function Documentation

◆ afterStart()

void yarp::os::Runnable::afterStart ( bool  success)
virtual

Should be called from the creator after the thread exists and before a call that requested the thread returns.

Reimplemented in RateThreadCallbackAdapter, yarp::os::impl::ThreadImpl, and ThreadCallbackAdapter.

Definition at line 22 of file Runnable.cpp.

◆ beforeStart()

void yarp::os::Runnable::beforeStart ( )
virtual

Should be called from the creator before the thread exists and before a call that requested the thread returns.

Reimplemented in RateThreadCallbackAdapter, yarp::os::impl::ThreadImpl, and ThreadCallbackAdapter.

Definition at line 19 of file Runnable.cpp.

◆ close()

void yarp::os::Runnable::close ( void  )
virtual

User-defined procedure for stopping execution.

There is no general-purpose way to achieve that.

Reimplemented in yarp::os::impl::PortCore, yarp::os::impl::PortCoreInputUnit, yarp::os::impl::PortCoreOutputUnit, yarp::os::impl::FallbackNameServer, ThreadCallbackAdapter, yarp::os::impl::ThreadImpl, and yarp::os::impl::FallbackNameClient.

Definition at line 16 of file Runnable.cpp.

◆ run()

◆ threadInit()

bool yarp::os::Runnable::threadInit ( )
virtual

Initialization method.

The thread executes this function when it starts and before "run". This is a good place to perform initialization tasks that need to be done by the thread itself (device drivers initialization, memory allocation etc). If the function returns false the thread quits and never calls "run". The return value of threadInit() is notified to the thread class and passed as a parameter to afterStart(). Note that afterStart() is called by the same thread that is executing the start method.

Reimplemented in RateThreadCallbackAdapter, yarp::os::impl::ThreadImpl, and ThreadCallbackAdapter.

Definition at line 25 of file Runnable.cpp.

◆ threadRelease()

void yarp::os::Runnable::threadRelease ( )
virtual

Release method.

The thread executes this function once when it exits, after the last "run". This is a good place to release resources that were initialized in threadInit() (release memory, and device driver resources).

Reimplemented in RateThreadCallbackAdapter, yarp::os::impl::ThreadImpl, and ThreadCallbackAdapter.

Definition at line 29 of file Runnable.cpp.


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