runtime_timer.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. uint32 bh_get_elpased_ms(uint32 * last_system_clock);
  12. struct _timer_ctx;
  13. typedef struct _timer_ctx * timer_ctx_t;
  14. typedef void (*timer_callback_f)(uint32 id, unsigned int owner);
  15. typedef void (*check_timer_expiry_f)(timer_ctx_t ctx);
  16. timer_ctx_t create_timer_ctx(timer_callback_f timer_handler,
  17. check_timer_expiry_f, int prealloc_num, unsigned int owner);
  18. void destroy_timer_ctx(timer_ctx_t);
  19. unsigned int timer_ctx_get_owner(timer_ctx_t ctx);
  20. uint32 sys_create_timer(timer_ctx_t ctx, int interval, bool is_period,
  21. bool auto_start);
  22. bool sys_timer_destroy(timer_ctx_t ctx, uint32 timer_id);
  23. bool sys_timer_cancel(timer_ctx_t ctx, uint32 timer_id);
  24. bool sys_timer_restart(timer_ctx_t ctx, uint32 timer_id, int interval);
  25. void cleanup_app_timers(timer_ctx_t ctx);
  26. int check_app_timers(timer_ctx_t ctx);
  27. int get_expiry_ms(timer_ctx_t ctx);
  28. #ifdef __cplusplus
  29. }
  30. #endif
  31. #endif /* LIB_BASE_RUNTIME_TIMER_H_ */