Can wait on async library calls
[akaros.git] / lib / asynccall.c
1 #include <inc/lib.h>
2 #include <inc/syscall.h>
3 #include <inc/queue.h>
4
5 async_desc_t* get_async_desc(void)
6 {
7         return POOL_GET(&async_desc_pool);
8 }
9
10 error_t waiton_async_call(async_desc_t* desc)
11 {
12         syscall_rsp_t rsp;
13         while (!(LIST_EMPTY(desc))) {
14                 waiton_syscall(LIST_FIRST(desc), &rsp);
15                 // consider processing the retval out of rsp
16                 LIST_REMOVE(LIST_FIRST(desc), next);
17         }
18         return 0;
19 }
20
21 syscall_desc_t* get_sys_desc(async_desc_t* desc)
22 {
23         syscall_desc_t* d = POOL_GET(&syscall_desc_pool);
24         if (d)
25         LIST_INSERT_TAIL(desc, d, next);
26         return d;
27 }