aboutsummaryrefslogtreecommitdiff
path: root/core/testing
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-01 14:28:02 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-02 14:54:32 -0400
commitd581dbbec52a7ddcb8dbc986240a5d5092659450 (patch)
treeafbc3066e24c6adf04cb8667411585971618137a /core/testing
parent5e3e958574a7654a70382fb04cea2212f8652ff0 (diff)
Keep test runner main thread from using 100% of a CPU core
Diffstat (limited to 'core/testing')
-rw-r--r--core/testing/runner.odin17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/testing/runner.odin b/core/testing/runner.odin
index dcc7c10ce..fbe413bb2 100644
--- a/core/testing/runner.odin
+++ b/core/testing/runner.odin
@@ -439,6 +439,23 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
thread.pool_start(&pool)
main_loop: for !thread.pool_is_empty(&pool) {
+ {
+ events_pending := thread.pool_num_done(&pool) > 0
+
+ if !events_pending {
+ poll_tasks: for &task_channel in task_channels {
+ if chan.len(task_channel.channel) > 0 {
+ events_pending = true
+ break poll_tasks
+ }
+ }
+ }
+
+ if !events_pending {
+ // Keep the main thread from pegging a core at 100% usage.
+ time.sleep(1 * time.Microsecond)
+ }
+ }
cycle_pool: for task in thread.pool_pop_done(&pool) {
data := cast(^Task_Data)(task.data)