private.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "faux/faux.h"
  2. #include "faux/list.h"
  3. #include "faux/time.h"
  4. #include "faux/sched.h"
  5. #define FAUX_SCHED_CLOCK_SOURCE CLOCK_MONOTONIC
  6. #define FAUX_SCHED_CYCLES_INFINITE (-1)
  7. struct faux_ev_s {
  8. struct timespec time; // Planned time of event
  9. struct timespec interval; // Time interval for periodic event
  10. int cycles_num; // Number of cycles for periodic event
  11. faux_sched_periodic_t periodic; // Periodic flag
  12. int id; // Type of event
  13. void *data; // Arbitrary data linked to event
  14. };
  15. struct faux_sched_s {
  16. faux_list_t *list;
  17. };
  18. C_DECL_BEGIN
  19. int faux_ev_compare(const void *first, const void *second);
  20. int faux_ev_compare_id(const void *key, const void *list_item);
  21. int faux_ev_compare_data(const void *key, const void *list_item);
  22. faux_ev_t *faux_ev_new(const struct timespec *time, int ev_id, void *data);
  23. void faux_ev_free(void *ptr);
  24. int faux_ev_periodic(faux_ev_t *ev,
  25. const struct timespec *interval, int cycles_num);
  26. int faux_ev_dec_cycles(faux_ev_t *ev, int *new_cycles_num);
  27. int faux_ev_reschedule(faux_ev_t *ev, const struct timespec *new_time);
  28. int faux_ev_reschedule_interval(faux_ev_t *ev);
  29. int faux_ev_time_left(faux_ev_t *ev, struct timespec *left);
  30. int faux_ev_id(const faux_ev_t *ev);
  31. void *faux_ev_data(const faux_ev_t *ev);
  32. const struct timespec *faux_ev_time(const faux_ev_t *ev);
  33. faux_sched_periodic_t faux_ev_is_periodic(faux_ev_t *ev);
  34. C_DECL_END