OpenDaVINCI  4.16.0
odcore::wrapper::RealtimeRunnable Class Referenceabstract

#include <RealtimeRunnable.h>

Inheritance diagram for odcore::wrapper::RealtimeRunnable:
Inheritance graph

Public Member Functions

virtual ~RealtimeRunnable ()
 
virtual bool isRunning ()=0
 

Protected Member Functions

 RealtimeRunnable (const uint32_t &periodInMicroseconds)
 
virtual void nextTimeSlice ()=0
 

Detailed Description

This class provides a threadable interface for realtime, periodic tasks. Only a POSIX implementation for Linux with rt-preempt is available at the moment.

It can be used as follows:

class MyRealtimeRunnable : public RealtimeRunnable {
public:
MyRealtimeRunnable() : RealtimeRunnable(100 * 1000)
{}
virtual void nextTimeSlice() {
// Do some things right here.
}
};
...
MyRealtimeRunnable rtr;
unique_ptr<Thread> t;
try {
t = unique_ptr<Thread>(ConcurrencyFactory::getInstance().createThread(rtr));
}
catch(string &s) {
clog << "Failed: " << s << endl;
}
if (t.get() != NULL) {
t->start();
}
...
// Do some different things.
...
if (t.get() != NULL) {
t->stop();
}

Constructor & Destructor Documentation

odcore::wrapper::RealtimeRunnable::RealtimeRunnable ( const uint32_t &  periodInMicroseconds)
protected

Constructor.

Parameters
periodInMicrosecondsDuration for the slice.
odcore::wrapper::RealtimeRunnable::~RealtimeRunnable ( )
virtual

Member Function Documentation

virtual bool odcore::wrapper::Runnable::isRunning ( )
pure virtualinherited

This method returns true, iff this runnable is in its internal state for running.

Returns
true iff this runnable is in its internal state for running.

Implemented in odcore::base::RealtimeService, odcore::base::Service, odcore::wrapper::SerialPort, odcore::wrapper::WIN32Impl::WIN32TCPAcceptor, odcore::wrapper::POSIX::POSIXTCPAcceptor, odcore::wrapper::POSIX::POSIXTCPConnection, and odcore::wrapper::WIN32Impl::WIN32TCPConnection.

virtual void odcore::wrapper::RealtimeRunnable::nextTimeSlice ( )
protectedpure virtual

This method is called periodically and must be implemented in derived classes.

Implemented in odcore::base::RealtimeService.