Flexiv RDK APIs  1.4
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 {
14 namespace rdk {
15 
21 class Scheduler
22 {
23 public:
30  virtual ~Scheduler();
31 
64  void AddTask(std::function<void(void)>&& callback, const std::string& task_name, int interval,
65  int priority, int cpu_affinity = -1);
66 
74  void Start();
75 
85  void Stop();
86 
92  int max_priority() const;
93 
99  int min_priority() const;
100 
105  size_t num_tasks() const;
106 
107 private:
108  class Impl;
109  std::unique_ptr<Impl> pimpl_;
110 };
111 
112 } /* namespace rdk */
113 } /* namespace flexiv */
114 
115 #endif /* FLEXIV_RDK_SCHEDULER_HPP_ */
Real-time scheduler that can simultaneously run multiple periodic tasks. Parameters for each task are...
Definition: scheduler.hpp:22
int min_priority() const
[Non-blocking] Get minimum available priority for user tasks.
int max_priority() const
[Non-blocking] Get 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] Create an instance and initialize the real-time scheduler.
size_t num_tasks() const
[Non-blocking] Get 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...