Flexiv RDK APIs  0.10
Scheduler.hpp
Go to the documentation of this file.
1 
6 #ifndef FLEXIVRDK_SCHEDULER_HPP_
7 #define FLEXIVRDK_SCHEDULER_HPP_
8 
9 #include <string>
10 #include <functional>
11 #include <memory>
12 
13 namespace flexiv {
14 
20 class Scheduler
21 {
22 public:
32  virtual ~Scheduler();
33 
73  void addTask(std::function<void(void)>&& callback,
74  const std::string& taskName, int interval, int priority,
75  int cpuAffinity = -1);
76 
84  void start();
85 
97  void stop();
98 
104  int maxPriority() const;
105 
111  int minPriority() const;
112 
117  size_t numTasks() const;
118 
119 private:
120  class Impl;
121  std::unique_ptr<Impl> m_pimpl;
122 };
123 
124 } /* namespace flexiv */
125 
126 #endif /* FLEXIVRDK_SCHEDULER_HPP_ */
Real-time scheduler that can simultaneously run multiple periodic tasks. Parameters for each task are...
Definition: Scheduler.hpp:21
size_t numTasks() const
[Non-blocking] Get number of tasks added to the scheduler.
void stop()
[Blocking] Stop all added tasks. The periodic execution will stop and all task threads will be closed...
void addTask(std::function< void(void)> &&callback, const std::string &taskName, int interval, int priority, int cpuAffinity=-1)
[Non-blocking] Add a new periodic task to the scheduler's task pool. Each task in the pool is assigne...
Scheduler()
[Blocking] Create a flexiv::Scheduler instance and initialize the real-time scheduler.
void start()
[Blocking] Start all added tasks. A dedicated thread will be created for each added task and the peri...
int minPriority() const
[Non-blocking] Get minimum available priority for user tasks.
int maxPriority() const
[Non-blocking] Get maximum available priority for user tasks.