aboutsummaryrefslogtreecommitdiff
path: root/core/thread
diff options
context:
space:
mode:
authorBruno Panuto <bl.panuto@gmail.com>2025-06-16 00:28:43 -0300
committerBruno Panuto <bl.panuto@gmail.com>2025-06-16 00:28:43 -0300
commit6874a4cdb06b662b5e6a5cb096865a14663bdecb (patch)
treed894aabe198dbc744d1dccc340a8088312b9a791 /core/thread
parent74f70bfbcb99dc60ef9cd3cebd5bd43b66e101f0 (diff)
fix: make pool_finish not hang when pool_start is not called
Diffstat (limited to 'core/thread')
-rw-r--r--core/thread/thread_pool.odin14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/thread/thread_pool.odin b/core/thread/thread_pool.odin
index 59bf90620..15b3a28d2 100644
--- a/core/thread/thread_pool.odin
+++ b/core/thread/thread_pool.odin
@@ -120,6 +120,20 @@ pool_join :: proc(pool: ^Pool) {
yield()
+ unstarted_count: int
+ for t in pool.threads {
+ flags := intrinsics.atomic_load(&t.flags)
+ if .Started not_in flags {
+ unstarted_count += 1
+ }
+ }
+
+ // most likely the user forgot to call `pool_start`
+ // exit here, so we don't hang forever
+ if len(pool.threads) == unstarted_count {
+ return
+ }
+
started_count: int
for started_count < len(pool.threads) {
started_count = 0