9
3

thr_timer.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Copyright (c) 2014 Monty Program Ab
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 or later of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  12. /* Prototypes when using thr_timer functions */
  13. #ifndef THR_TIMER_INCLUDED
  14. #define THR_TIMER_INCLUDED
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. typedef struct st_timer {
  19. struct timespec expire_time;
  20. my_bool expired;
  21. uint index_in_queue;
  22. void (*func)(void*);
  23. void *func_arg;
  24. } thr_timer_t;
  25. /* Main functions for library */
  26. my_bool init_thr_timer(uint init_size_for_timer_queue);
  27. void end_thr_timer();
  28. /* Functions for handling one timer */
  29. void thr_timer_init(thr_timer_t *timer_data, void(*function)(void*),
  30. void *arg);
  31. my_bool thr_timer_settime(thr_timer_t *timer_data, ulonglong microseconds);
  32. void thr_timer_end(thr_timer_t *timer_data);
  33. #ifdef __cplusplus
  34. }
  35. #endif /* __cplusplus */
  36. #endif /* THR_TIMER_INCLUDED */