103 sched.sched_priority = 0;
106 sched.sched_priority = priority;
113 if (sched.sched_priority != 0)
115 if (pthread_setschedparam(
thread_.native_handle(), SCHED_FIFO, &sched) != 0)
117 ROS_WARN(
"Failed to set thread priority for worker [%s]: %s",
options_.
name_.c_str(), strerror(errno));
128 if (wait &&
thread_.joinable())
138 ROS_ERROR(
"Cannot change timestep of Worker [%s] to %f, invalid value.",
options_.
name_.c_str(), timeStep);
142 if (!std::isinf(timeStep))
161 clock_gettime(CLOCK_MONOTONIC, &now);
void stop(const bool wait=true)
WorkerCallbackFailureReaction callbackFailureReaction_
std::function< void(void)> WorkerCallbackFailureReaction
bool start(const int priority=0)
void setEnforceRate(const bool enforceRate)
std::atomic< double > timeStep_
Time step in seconds.
std::atomic< bool > done_
std::function< bool(const WorkerEvent &)> WorkerCallback
std::atomic< bool > running_
RateOptions & getOptions()
void setTimestep(const double timeStep)
const timespec & getSleepEndTime() const
std::atomic< bool > enforceRate_
Boolean indicating whether the rate should be enforced.
std::string name_
Name for printing.