diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:08:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:08:18 +0000 |
commit | 5da14042f70711ea5cf66e034699730335462f66 (patch) | |
tree | 0f6354ccac934ed87a2d555f45be4c831cf92f4a /src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/timer.ts | |
parent | Releasing debian version 1.44.3-2. (diff) | |
download | netdata-5da14042f70711ea5cf66e034699730335462f66.tar.xz netdata-5da14042f70711ea5cf66e034699730335462f66.zip |
Merging upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/timer.ts')
-rw-r--r-- | src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/timer.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/timer.ts b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/timer.ts new file mode 100644 index 000000000..2e3f69d29 --- /dev/null +++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/timer.ts @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +// The entry file of your WebAssembly module. +import * as console from '../wamr_app_lib/console' +import * as timer from '../wamr_app_lib/timer' + +/* clousure is not implemented yet, we need to declare global variables + so that they can be accessed inside a callback function */ +var cnt = 0; +var my_timer: timer.user_timer; + +export function on_init(): void { + /* The callback function will be called every 2 second, + and will stop after 10 calls */ + my_timer = timer.setInterval(() => { + cnt ++; + console.log((cnt * 2).toString() + " seconds passed"); + + if (cnt >= 10) { + timer.timer_cancel(my_timer); + console.log("Stop Timer"); + } + }, 2000); +} + +export function on_destroy(): void { + +} + +/* Function below are requred by wamr runtime, don't remove or modify them */ +export function _on_timer_callback(on_timer_id: i32): void { + timer.on_timer_callback(on_timer_id); +}
\ No newline at end of file |