3 #include <ccan/typesafe_cb/typesafe_cb.h>
8 /* Operations for the parent. */
10 /* Create a new sharable pool. */
11 struct at_pool *at_pool(unsigned long size);
13 /* Talloc off this to allocate from within the pool. */
14 const void *at_pool_ctx(struct at_pool *atp);
16 /* Creating an antithread via fork(). Returned athread is child of pool. */
17 #define at_run(pool, fn, arg) \
19 typesafe_cb_preargs(void *, (fn), (arg), struct at_pool *), \
22 /* Fork and execvp, with added arguments for child to grab.
23 * Returned athread is child of pool. */
24 struct athread *at_spawn(struct at_pool *pool, void *arg, char *cmdline[]);
26 /* The fd to poll on */
27 int at_fd(struct athread *at);
29 /* What's the antithread saying? Blocks if fd not ready. */
30 void *at_read(struct athread *at);
32 /* Say something to a child (async). */
33 void at_tell(struct athread *at, const void *status);
35 /* Operations for the children */
36 /* For child to grab arguments from command line (removes them) */
37 struct at_pool *at_get_pool(int *argc, char *argv[], void **arg);
39 /* Say something to our parent (async). */
40 void at_tell_parent(struct at_pool *pool, const void *status);
42 /* What's the parent saying? Blocks if fd not ready. */
43 void *at_read_parent(struct at_pool *pool);
45 /* The fd to poll on */
46 int at_parent_fd(struct at_pool *pool);
48 /* Locking: any talloc pointer. */
49 void at_lock(void *obj);
50 void at_unlock(void *obj);
52 void at_lock_all(struct at_pool *pool);
53 void at_unlock_all(struct at_pool *pool);
55 /* Internal function */
56 struct athread *_at_run(struct at_pool *pool,
57 void *(*fn)(struct at_pool *, void *arg),
60 #endif /* ANTITHREAD_H */