From eba413853fc287de6862565db72915bca3c53cd0 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 10 Aug 2020 15:21:34 +0300 Subject: [PATCH] compiler_errors_test.v: use work.close() instead of sentinel tasks --- vlib/v/compiler_errors_test.v | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/vlib/v/compiler_errors_test.v b/vlib/v/compiler_errors_test.v index 331a557b57..1d08c0845b 100644 --- a/vlib/v/compiler_errors_test.v +++ b/vlib/v/compiler_errors_test.v @@ -67,17 +67,13 @@ fn (mut tasks []TaskDescription) run() { vjobs := runtime.nr_jobs() mut bench := benchmark.new_benchmark() bench.set_total_expected_steps(tasks.len) - // TODO: close work channel instead of using sentinel items - task_sentinel := TaskDescription{ - path: '' - } - mut work := sync.new_channel(tasks.len + vjobs) + mut work := sync.new_channel(tasks.len) mut results := sync.new_channel(tasks.len) for i in 0 .. tasks.len { work.push(&tasks[i]) } + work.close() for _ in 0 .. vjobs { - work.push(&task_sentinel) go work_processor(mut work, mut results) } for _ in 0 .. tasks.len { @@ -112,8 +108,7 @@ fn (mut tasks []TaskDescription) run() { fn work_processor(mut work sync.Channel, mut results sync.Channel) { for { mut task := TaskDescription{} - work.pop(&task) - if task.path == '' { + if !work.pop(&task) { break } sw := time.new_stopwatch({})