From a430aa79070b25e0863dfe8d729b27b5346199c6 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Thu, 10 Jul 2025 21:24:03 -0400 Subject: Initial version --- src/test/test.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/test.c (limited to 'src/test/test.c') diff --git a/src/test/test.c b/src/test/test.c new file mode 100644 index 0000000..652e0f4 --- /dev/null +++ b/src/test/test.c @@ -0,0 +1,33 @@ +#include "async.h" +#include +#include + +static int func2(int a) { + sleep(a); + return 2*a; +} + +/* +static void func1(int a) { + printf("func1: %d\n", func2(a)); +} + +static void func3() { + printf("func3!\n"); +} +*/ + +int main() { + async_pool_t* pool = async_pool_create(2); + async_thunk_id_t id1 = async_submit(pool, func2, 7, true); + async_thunk_id_t id2 = async_submit(pool, func2, 3, true); + async_thunk_id_t id3 = async_submit(pool, func2, 1, true); + async_thunk_id_t id4 = async_submit(pool, func2, 5, true); + async_pool_join(pool); + printf("3: %d\n", (int) async_await(pool, id3)); + printf("4: %d\n", (int) async_await(pool, id4)); + printf("1: %d\n", (int) async_await(pool, id1)); + printf("2: %d\n", (int) async_await(pool, id2)); + async_pool_destroy(pool); + return 0; +} -- cgit v1.2.3