10 #define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
12 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
179 this->helper = helper;
186 this->helper = &helper;
207 this->helper = &helper;
215 this->helper = helper;
225 yCInfo(RATETHREAD,
"Setting framerate to: %.0lf[Hz] (thread period %f[s])\n",
framerate, period);
227 yCInfo(RATETHREAD,
"No framerate specified, polling the device");
249 if (helper !=
nullptr) {
256 if (helper !=
nullptr) {
264 if (helper !=
nullptr) {
271 if (helper !=
nullptr) {
278 if (helper !=
nullptr) {
An abstraction for a periodic thread.
void resetStat()
Reset thread statistics.
bool setPeriod(double period)
Set the (new) period of the thread.
int getPriority() const
Query the current priority of the thread, if the OS supports that.
unsigned int getIterations() const
Return the number of iterations performed since last reset.
bool isRunning() const
Returns true when the thread is started, false otherwise.
int getPolicy() const
Query the current scheduling policy of the thread, if the OS supports that.
bool isSuspended() const
Returns true when the thread is suspended, false otherwise.
void resume()
Resume the thread if previously suspended.
void suspend()
Suspend the thread, the thread keeps running by doLoop is never executed.
int setPriority(int priority, int policy=-1)
Set the priority and scheduling policy of the thread, if the OS supports that.
void askToStop()
Stop the thread.
double getEstimatedUsed() const
Return the estimated duration of the run() function since last reset.
double getEstimatedPeriod() const
Return estimated period since last reset.
bool start()
Call this to start the thread.
void step()
Call this to "step" the thread rather than starting it.
double getPeriod() const
Return the current period of the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
void threadRelease() override
Release method.
virtual ~RateThreadWrapper()
Runnable * getAttachment() const
bool threadInit() override
Initialization method.
void afterStart(bool success) override
Called just after a new thread starts (or fails to start), this is executed by the same thread that c...
void beforeStart() override
Called just before a new thread starts.
RateThreadWrapper()
Default constructor.
virtual bool attach(Runnable &helper)
bool open(double framerate=-1, bool polling=false)
void run() override
Loop function.
void afterStart(bool success) override
Called just after a new thread starts (or fails to start), this is executed by the same thread that c...
int getPriority()
Query the current priority of the thread, if the OS supports that.
bool step()
Call this to "step" the thread rather than starting it.
int setPriority(int priority, int policy=-1)
Set the priority and scheduling policy of the thread, if the OS supports that.
bool isSuspended()
Returns true when the thread is suspended, false otherwise.
bool setRate(int period)
Set the (new) rate of the thread.
double getEstPeriod()
Return estimated period since last reset.
void threadRelease() override
Release method.
void resume()
Resume the thread if previously suspended.
double getEstUsed()
Return the estimated duration of the run() function since last reset.
void suspend()
Suspend the thread, the thread keeps running by doLoop is never executed.
bool isRunning()
Returns true when the thread is started, false otherwise.
RateThread(int period)
Constructor.
int getPolicy()
Query the current scheduling policy of the thread, if the OS supports that.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
void askToStop()
Stop the thread.
bool threadInit() override
Initialization method.
void resetStat()
Reset thread statistics.
double getRate()
Return the current rate of the thread.
void beforeStart() override
Called just before a new thread starts.
unsigned int getIterations()
Return the number of iterations performed since last reset.
A class that can be managed by another thread.
virtual bool threadInit()
Initialization method.
virtual void run()
Body to run - could be periodic or continuous.
virtual void afterStart(bool success)
Should be called from the creator after the thread exists and before a call that requested the thread...
virtual void beforeStart()
Should be called from the creator before the thread exists and before a call that requested the threa...
virtual void threadRelease()
Release method.
virtual ~SystemRateThread()
SystemRateThread(int period)
#define yCInfo(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
An interface to the operating system, including Port based communication.
constexpr char framerate[]
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.