1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- /*
- * 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(unsigned 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 *);
- unsigned 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);
- uint32_t ms2Divider(uint64_t millisec);
- 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_ */
|