diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-07-04 15:01:18 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-07-06 15:24:38 -0400 |
commit | 379dee8a47480938c067fca0acd01dea9b5afa33 (patch) | |
tree | f6e41efe2e019d360bc38c7229914c6b17724c13 /src/ioq.c | |
parent | 187ef092b6ea0f92dac53fbd2deb71379400446e (diff) | |
download | bfs-379dee8a47480938c067fca0acd01dea9b5afa33.tar.xz |
ioq: New ioq_capacity() function
Diffstat (limited to 'src/ioq.c')
-rw-r--r-- | src/ioq.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -355,6 +355,10 @@ fail: return NULL; } +size_t ioq_capacity(const struct ioq *ioq) { + return ioq->depth - ioq->size; +} + int ioq_opendir(struct ioq *ioq, struct bfs_dir *dir, int dfd, const char *path, void *ptr) { if (ioq->size >= ioq->depth) { return -1; @@ -382,7 +386,6 @@ struct ioq_res *ioq_pop(struct ioq *ioq) { } union ioq_cmd *cmd = ioqq_pop(ioq->ready); - --ioq->size; return &cmd->res; } @@ -396,11 +399,13 @@ struct ioq_res *ioq_trypop(struct ioq *ioq) { return NULL; } - --ioq->size; return &cmd->res; } void ioq_free(struct ioq *ioq, struct ioq_res *res) { + bfs_assert(ioq->size > 0); + --ioq->size; + arena_free(&ioq->cmds, (union ioq_cmd *)res); } |