summaryrefslogtreecommitdiff
path: root/src/test/test.c
diff options
context:
space:
mode:
authorCarson Fleming <cflems@cflems.net>2025-07-10 21:24:03 -0400
committerCarson Fleming <cflems@cflems.net>2025-07-10 21:24:34 -0400
commita430aa79070b25e0863dfe8d729b27b5346199c6 (patch)
tree4887652a2ffb7c0eb8dd54e10ac45ce14568b4fb /src/test/test.c
parent52deba5ff9747af1b456edd4559dd63e27e1ae19 (diff)
downloadasyncc-a430aa79070b25e0863dfe8d729b27b5346199c6.tar.gz
Initial version
Diffstat (limited to 'src/test/test.c')
-rw-r--r--src/test/test.c33
1 files changed, 33 insertions, 0 deletions
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 <stdio.h>
+#include <unistd.h>
+
+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;
+}