diff options
author | Maria Matejka <mq@ucw.cz> | 2021-11-30 18:16:49 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2021-11-30 21:38:25 +0100 |
commit | 385b3ea3956aefc2868cdd838fc0a90f1d8a7857 (patch) | |
tree | d954b853724153e4a2411d57be5f29e5b9236251 /lib/io-loop.h | |
parent | ab0994a10c26bd76b4154a675267d96d19dfb509 (diff) |
For safer memory allocations, resources are bound to loops.
Also all loops have their basic resource pool for allocations which are
auto-freed when the loop is stopping.
Diffstat (limited to 'lib/io-loop.h')
-rw-r--r-- | lib/io-loop.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/io-loop.h b/lib/io-loop.h index 25f1b2a3..386a31d5 100644 --- a/lib/io-loop.h +++ b/lib/io-loop.h @@ -20,15 +20,15 @@ void sk_reloop(sock *s, struct birdloop *loop); extern struct birdloop main_birdloop; -/* Start a new birdloop owned by given pool and domain */ +/* Start a new birdloop owned by given pool and domain. + * The loop allocates its internal pool for local allocations + * which is freed when the loop itself is stopped. */ struct birdloop *birdloop_new(pool *p, uint order, const char *name); -/* Stop the loop. At the end, the @stopped callback is called unlocked in tail - * position to finish cleanup. Run birdloop_free() from that callback to free - * the loop itself. */ +/* Stop the loop. At the end, the @stopped callback is called with locked + * parent to finish cleanup. The loop then frees itself together with its pool. */ void birdloop_stop(struct birdloop *loop, void (*stopped)(void *data), void *data); void birdloop_stop_self(struct birdloop *loop, void (*stopped)(void *data), void *data); -void birdloop_free(struct birdloop *loop); /* Get birdloop's event list */ event_list *birdloop_event_list(struct birdloop *loop); @@ -36,6 +36,9 @@ event_list *birdloop_event_list(struct birdloop *loop); /* Get birdloop's time heap */ struct timeloop *birdloop_time_loop(struct birdloop *loop); +/* Get birdloop's resource pool */ +pool *birdloop_pool(struct birdloop *loop); + /* Enter and exit the birdloop */ void birdloop_enter(struct birdloop *loop); void birdloop_leave(struct birdloop *loop); |