summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/app-framework/base/app/wa-inc/timer_wasm_app.h
blob: cf158a36586f42d35dac2c21805d5446a2cfe840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * Copyright (C) 2019 Intel Corporation.  All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */

#ifndef _AEE_TIMER_H_
#define _AEE_TIMER_H_

#include "bh_platform.h"

#ifdef __cplusplus
extern "C" {
#endif

/* board producer define user_timer */
struct user_timer;
typedef struct user_timer *user_timer_t;

/**
 * @typedef on_user_timer_update_f
 *
 * @brief Define the signature of callback function for API api_timer_create().
 *
 * @param timer the timer
 *
 * @see api_timer_create
 */
typedef void (*on_user_timer_update_f)(user_timer_t timer);

/*
 *****************
 * Timer APIs
 *****************
 */

/**
 * @brief Create timer.
 *
 * @param interval timer interval
 * @param is_period whether the timer is periodic
 * @param auto_start whether start the timer immediately after created
 * @param on_timer_update callback function called when timer expired
 *
 * @return the timer created if success, NULL otherwise
 */
user_timer_t
api_timer_create(int interval, bool is_period, bool auto_start,
                 on_user_timer_update_f on_timer_update);

/**
 * @brief Cancel timer.
 *
 * @param timer the timer to cancel
 */
void
api_timer_cancel(user_timer_t timer);

/**
 * @brief Restart timer.
 *
 * @param timer the timer to cancel
 * @param interval the timer interval
 */
void
api_timer_restart(user_timer_t timer, int interval);

#ifdef __cplusplus
}
#endif

#endif