/* * timer.h * * Created on: Nov 9, 2015 * Author: Philipp Hinz */ #ifndef TIMER_H_ #define TIMER_H_ /** * Timer Class * This class allows the creation of multiple timers that are based * by a divider on a single system timer. */ class timer { public: timer(void (*handler)(void)); timer(void *(*handler)(void *)); void setDivider(int divider); int getDivider(); void call(); void start(); void stop(); bool isActive(); timer *next; /**< contains the pointer on the next timer element of the list */ private: void (*handler)(void); void *(*thandler)(void *); int divider; int id = 0; /**< needed to identify the threads */ bool active; bool asThread; /**< defines if the handler should be called or not */ pthread_t thread; }; void initTimers(void); void stopTimers(void); void *nullThread(void *threadid); #define SIG SIGRTMIN #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) #define CLOCKID CLOCK_REALTIME #endif /* TIMER_H_ */