47 48
81
Remove need for malloc by Coroutine, and add Coroutine_Err
on 12:28 AM Feb 20 2026
80
81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef FUTURE_H
#define FUTURE_H
#include <stdbool.h>
typedef struct Future Future;
typedef struct Future_vfptrs_t {
void (*dtor)(Future *);
void (*await)(Future *);
void (*set_result)(Future *, bool, void *);
} Future_vfptrs_t;
extern void _Future_Await(Future *fut);
extern void _Future_SetResult(Future *fut, bool canceled, void *res);
// Notified when a Future is done (has a result or is canceled)
typedef void (*Future_Watcher)(void *me, Future *fut);
extern void Future_ctor(Future *fut);
extern Future *Future_New(void);
extern void Future_dtor(Future *fut);
extern void Future_Delete(Future *fut);
extern void Future_SetResult(Future *fut, bool canceled, void *value);
extern bool Future_GetResult(Future *fut, void **res);
extern void Future_AddWatcher(Future *fut, Future_Watcher watcher, void *me);
extern void Future_RemoveWatcher(Future *fut, Future_Watcher watcher, void *me);
extern bool Future_Await(Future *fut, void **res);
#include "future.def.h"
#endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef FUTURE_H
#define FUTURE_H
#include <stdbool.h>
#include "coroutine.h"
typedef struct Future Future;
typedef struct Future_vfptrs_t {
void (*dtor)(Future *);
void (*await)(Future *);
void (*set_result)(Future *, bool, void *);
} Future_vfptrs_t;
extern void _Future_Await(Future *fut);
extern void _Future_SetResult(Future *fut, bool canceled, void *res);
// Notified when a Future is done (has a result or is canceled)
typedef void (*Future_Watcher)(void *me, Future *fut);
extern void Future_ctor(Future *fut);
extern Future *Future_New(void);
extern void Future_dtor(Future *fut);
extern void Future_Delete(Future *fut);
extern void Future_SetResult(Future *fut, bool canceled, void *value);
extern Coroutine_Err Future_GetResult(Future *fut, void **res);
extern void Future_AddWatcher(Future *fut, Future_Watcher watcher, void *me);
extern void Future_RemoveWatcher(Future *fut, Future_Watcher watcher, void *me);
extern Coroutine_Err Future_Await(Future *fut, void **res);
#include "future.def.h"
#endif