aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2025-06-16 10:50:35 +0200
committerGitHub <noreply@github.com>2025-06-16 10:50:35 +0200
commit795ceec2cdbd47fe7ae0181e1fc5d17062eea062 (patch)
tree310fa860813db5fea52a3a6911c0da4481e0534d /core
parent771c1c4332efdacd2a83f87bf3314eb749c761b5 (diff)
parent6874a4cdb06b662b5e6a5cb096865a14663bdecb (diff)
Merge pull request #5327 from nubunto/fix/pool-join-hangs
fix: pool_join hangs if no threads are started
Diffstat (limited to 'core')
-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