瀏覽代碼

Do a bit less work for pool_join.

Jeroen van Rijn 3 年之前
父節點
當前提交
58fc305b11
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      core/thread/thread_pool.odin

+ 5 - 1
core/thread/thread_pool.odin

@@ -103,14 +103,18 @@ pool_join :: proc(pool: ^Pool) {
 
 	yield()
 
+	// 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 {
-				join(t)
 				started_count += 1
 			}
+			if .Joined not_in t.flags {
+				join(t)
+			}
 		}
 	}
 }