Flexiv RDK APIs  2.1
scheduler.hpp
Go to the documentation of this file.
1 
6 #ifndef FLEXIV_RDK_SCHEDULER_HPP_
7 #define FLEXIV_RDK_SCHEDULER_HPP_
8 
9 #include <string>
10 #include <functional>
11 #include <memory>
12 
13 namespace flexiv::rdk {
14 
20 class Scheduler
21 {
22 public:
29  virtual ~Scheduler();
30 
63  void AddTask(std::function<void(void)>&& callback, const std::string& task_name, int interval,
64  int priority, int cpu_affinity = -1);
65 
73  void Start();
74 
84  void Stop();
85 
91  int max_priority() const;
92 
98  int min_priority() const;
99 
104  size_t num_tasks() const;
105 
106 private:
107  class Impl;
108  std::unique_ptr<Impl> pimpl_;
109 };
110 
111 } /* namespace flexiv::rdk */
112 
113 #endif /* FLEXIV_RDK_SCHEDULER_HPP_ */
Real-time scheduler that can simultaneously run multiple periodic tasks. Parameters for each task are...
Definition: scheduler.hpp:21
int min_priority() const
[Non-blocking] Minimum available priority for user tasks.
int max_priority() const
[Non-blocking] Maximum available priority for user tasks.
void AddTask(std::function< void(void)> &&callback, const std::string &task_name, int interval, int priority, int cpu_affinity=-1)
[Non-blocking] Add a new periodic task to the scheduler's task pool. Each task in the pool is assigne...
void Stop()
[Blocking] Stop all added tasks. The periodic execution will stop and all task threads will be closed...
Scheduler()
[Blocking] Instantiate a real-time scheduler.
size_t num_tasks() const
[Non-blocking] Number of tasks added to the scheduler.
void Start()
[Blocking] Start all added tasks. A dedicated thread will be created for each added task and the peri...