runtime_timer.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef LIB_BASE_RUNTIME_TIMER_H_
  6. #define LIB_BASE_RUNTIME_TIMER_H_
  7. #include "bh_platform.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. uint64
  12. bh_get_tick_ms(void);
  13. uint32
  14. bh_get_elpased_ms(uint32 *last_system_clock);
  15. struct _timer_ctx;
  16. typedef struct _timer_ctx *timer_ctx_t;
  17. typedef void (*timer_callback_f)(unsigned int id, unsigned int owner);
  18. typedef void (*check_timer_expiry_f)(timer_ctx_t ctx);
  19. timer_ctx_t
  20. create_timer_ctx(timer_callback_f timer_handler, check_timer_expiry_f,
  21. int prealloc_num, unsigned int owner);
  22. void destroy_timer_ctx(timer_ctx_t);
  23. unsigned int
  24. timer_ctx_get_owner(timer_ctx_t ctx);
  25. uint32
  26. sys_create_timer(timer_ctx_t ctx, int interval, bool is_period,
  27. bool auto_start);
  28. bool
  29. sys_timer_destroy(timer_ctx_t ctx, uint32 timer_id);
  30. bool
  31. sys_timer_cancel(timer_ctx_t ctx, uint32 timer_id);
  32. bool
  33. sys_timer_restart(timer_ctx_t ctx, uint32 timer_id, int interval);
  34. void
  35. cleanup_app_timers(timer_ctx_t ctx);
  36. uint32
  37. check_app_timers(timer_ctx_t ctx);
  38. uint32
  39. get_expiry_ms(timer_ctx_t ctx);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* LIB_BASE_RUNTIME_TIMER_H_ */