aboutsummaryrefslogtreecommitdiff
path: root/core/thread/thread_pool.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-05-13 15:17:08 +0200
committerGitHub <noreply@github.com>2022-05-13 15:17:08 +0200
commit286f782e5ec8da4e573cfd1786f480200fe85587 (patch)
tree58ceadfeaf56338866d937c0ea3ed7fa50876b48 /core/thread/thread_pool.odin
parentf50399e394419df4c1d48edccc3145d45ac6859f (diff)
parent58fc305b11f1f4fb4b5f7de037947f905e05f849 (diff)
Merge pull request #1786 from Kelimion/thread_fix
Fix thread pool join.
Diffstat (limited to 'core/thread/thread_pool.odin')
-rw-r--r--core/thread/thread_pool.odin16
1 files changed, 14 insertions, 2 deletions
diff --git a/core/thread/thread_pool.odin b/core/thread/thread_pool.odin
index af80da9aa..840cecfec 100644
--- a/core/thread/thread_pool.odin
+++ b/core/thread/thread_pool.odin
@@ -39,6 +39,7 @@ Pool :: struct {
threads: []^Thread,
+
tasks: [dynamic]Task,
tasks_done: [dynamic]Task,
}
@@ -102,8 +103,19 @@ pool_join :: proc(pool: ^Pool) {
yield()
- for t in pool.threads {
- join(t)
+ // Because we already stopped the pool, there's no need to take a lock here.
+
+ started_count: int
+ for started_count < len(pool.threads) {
+ started_count = 0
+ for t in pool.threads {
+ if .Started in t.flags {
+ started_count += 1
+ }
+ if .Joined not_in t.flags {
+ join(t)
+ }
+ }
}
}