runtime_timer.h 1.3 KB

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