2019-05-07 02:18:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
2019-11-11 23:45:21 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2019-05-07 02:18:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIB_BASE_RUNTIME_TIMER_H_
|
|
|
|
#define LIB_BASE_RUNTIME_TIMER_H_
|
|
|
|
|
|
|
|
#include "bh_platform.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-10-14 01:12:07 +00:00
|
|
|
uint64
|
2022-10-20 13:26:57 +00:00
|
|
|
bh_get_tick_ms(void);
|
2021-10-14 01:12:07 +00:00
|
|
|
uint32
|
|
|
|
bh_get_elpased_ms(uint32 *last_system_clock);
|
2019-05-07 02:18:18 +00:00
|
|
|
|
|
|
|
struct _timer_ctx;
|
2021-10-14 01:12:07 +00:00
|
|
|
typedef struct _timer_ctx *timer_ctx_t;
|
2020-06-02 06:53:06 +00:00
|
|
|
typedef void (*timer_callback_f)(unsigned int id, unsigned int owner);
|
2019-05-07 02:18:18 +00:00
|
|
|
typedef void (*check_timer_expiry_f)(timer_ctx_t ctx);
|
|
|
|
|
2021-10-14 01:12:07 +00:00
|
|
|
timer_ctx_t
|
|
|
|
create_timer_ctx(timer_callback_f timer_handler, check_timer_expiry_f,
|
|
|
|
int prealloc_num, unsigned int owner);
|
2019-05-07 02:18:18 +00:00
|
|
|
void destroy_timer_ctx(timer_ctx_t);
|
2021-10-14 01:12:07 +00:00
|
|
|
unsigned int
|
|
|
|
timer_ctx_get_owner(timer_ctx_t ctx);
|
|
|
|
|
|
|
|
uint32
|
|
|
|
sys_create_timer(timer_ctx_t ctx, int interval, bool is_period,
|
|
|
|
bool auto_start);
|
|
|
|
bool
|
|
|
|
sys_timer_destroy(timer_ctx_t ctx, uint32 timer_id);
|
|
|
|
bool
|
|
|
|
sys_timer_cancel(timer_ctx_t ctx, uint32 timer_id);
|
|
|
|
bool
|
|
|
|
sys_timer_restart(timer_ctx_t ctx, uint32 timer_id, int interval);
|
|
|
|
void
|
|
|
|
cleanup_app_timers(timer_ctx_t ctx);
|
|
|
|
uint32
|
|
|
|
check_app_timers(timer_ctx_t ctx);
|
|
|
|
uint32
|
|
|
|
get_expiry_ms(timer_ctx_t ctx);
|
2019-05-07 02:18:18 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* LIB_BASE_RUNTIME_TIMER_H_ */
|