Threading & Time Utilities#

These helper classes provide task scheduling, thread management, and lightweight timing measurements. They are lower-level building blocks that sit beneath the main robot client APIs.

Headers

Type

Header

rb::EventLoop

#include <rby1-sdk/base/event_loop.h>

rb::Thread

#include <rby1-sdk/base/thread.h>

rb::TimeWatch

#include <rby1-sdk/base/time_util.h>

Public Member Functions

Type or method group

Purpose

Notes

rb::EventLoop

Queue one-shot or cyclic work, pause execution, and wait for tasks.

Use in support utilities rather than high-level robot control.

rb::Thread

Configure thread name, affinity, and OS priority before running work.

Useful when timing behavior matters.

rb::TimeWatch

Record elapsed time measurements.

Handy in profiling and timing-sensitive utilities.

Detailed Reference

class EventLoop#

Public Functions

inline EventLoop()#
inline explicit EventLoop(std::unique_ptr<Thread> thd)#
inline ~EventLoop() noexcept#
template<typename F, typename ...A, typename R = std::invoke_result_t<std::decay_t<F>, std::decay_t<A>...>>
inline R DoTask(F &&task, A&&... args)#
inline void Pause()#
inline void PurgeTasks()#
inline void PushCyclicTask(const std::function<void()> &cb, std::chrono::nanoseconds period, std::chrono::nanoseconds offset = std::chrono::nanoseconds{0})#
template<typename F, typename ...A>
inline void PushLoopTask(F &&task, A&&... args)#
template<typename F, typename ...A>
inline void PushTask(F &&task, A&&... args)#
inline void Stop()#
template<typename F, typename ...A, typename R = std::invoke_result_t<std::decay_t<F>, std::decay_t<A>...>>
inline std::future<R> Submit(F &&task, A&&... args)#
inline void Unpause()#
inline void WaitForTasks() noexcept#
class Thread#

Public Types

using Functor = std::function<void()>#

Public Functions

inline Thread(std::string name = "", int cpuid = -1, int priority = 0, int policy = POLICY_DEFAULT_VALUE)#
inline ~Thread()#
inline bool IsRunning() const#
inline void Join()#
inline void SetAffinity(int cpuid)#
inline void SetName(const std::string &name)#
inline void SetOSPriority(int priority, int policy)#
inline void StartFunc(const Functor &func)#
class TimeWatch#

Public Functions

inline TimeWatch()#
inline long GetDurationInNs(bool record = false)#
inline void Record()#

Related Types

Examples

  • real_time_control_command.cpp is the most relevant example whenever execution timing matters.