diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-11-26 14:31:22 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-11-27 21:03:36 -0500 |
commit | 46e0c0bccbee21903efc9c924874970e251dde48 (patch) | |
tree | f248864843698d70fd065469fe41c414945c9b78 /src/ioq.c | |
parent | f05d65e5cf4b376a6bf1eeed17356f8e7767b389 (diff) | |
download | bfs-46e0c0bccbee21903efc9c924874970e251dde48.tar.xz |
ioq: Set the worker thread names to ioq-%d
Diffstat (limited to 'src/ioq.c')
-rw-r--r-- | src/ioq.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -918,7 +918,8 @@ static void ioq_ring_exit(struct ioq_thread *thread) { } /** Create an I/O queue thread. */ -static int ioq_thread_create(struct ioq *ioq, struct ioq_thread *thread) { +static int ioq_thread_create(struct ioq *ioq, size_t i) { + struct ioq_thread *thread = &ioq->threads[i]; thread->parent = ioq; ioq_ring_init(ioq, thread); @@ -928,6 +929,11 @@ static int ioq_thread_create(struct ioq *ioq, struct ioq_thread *thread) { return -1; } + char name[16]; + if (snprintf(name, sizeof(name), "ioq-%zu", i) >= 0) { + thread_setname(thread->id, name); + } + return 0; } @@ -962,7 +968,7 @@ struct ioq *ioq_create(size_t depth, size_t nthreads) { ioq->nthreads = nthreads; for (size_t i = 0; i < nthreads; ++i) { - if (ioq_thread_create(ioq, &ioq->threads[i]) != 0) { + if (ioq_thread_create(ioq, i) != 0) { ioq->nthreads = i; goto fail; } |