33 lines1.0 KB
Newer
Older
-
+
commited
{line.log.rev}
on
8 months ago
37
1
#ifndef FUTURE_H
2
#define FUTURE_H
3
#include <stdbool.h>
3 months ago
4
#include "coroutine.h"
8 months ago
37
5
6
typedef struct Future Future;
7
8
9
typedef struct Future_vfptrs_t {
10
void (*dtor)(Future *);
11
void (*await)(Future *);
12
void (*set_result)(Future *, bool, void *);
13
} Future_vfptrs_t;
14
7 months ago
15
extern void _Future_Await(Future *fut);
16
extern void _Future_SetResult(Future *fut, bool canceled, void *res);
8 months ago
37
17
18
// Notified when a Future is done (has a result or is canceled)
19
typedef void (*Future_Watcher)(void *me, Future *fut);
20
7 months ago
21
extern void Future_ctor(Future *fut);
7 months ago
22
extern Future *Future_New(void);
7 months ago
23
extern void Future_dtor(Future *fut);
24
extern void Future_Delete(Future *fut);
25
extern void Future_SetResult(Future *fut, bool canceled, void *value);
3 months ago
26
extern Coroutine_Err Future_GetResult(Future *fut, void **res);
7 months ago
27
extern void Future_AddWatcher(Future *fut, Future_Watcher watcher, void *me);
28
extern void Future_RemoveWatcher(Future *fut, Future_Watcher watcher, void *me);
3 months ago
29
extern Coroutine_Err Future_Await(Future *fut, void **res);
8 months ago
37
30
31
#include "future.def.h"
32
#endif
33