compiler_errors_test.v: use work.close() instead of sentinel tasks
parent
5e2824e2f2
commit
eba413853f
|
@ -67,17 +67,13 @@ fn (mut tasks []TaskDescription) run() {
|
||||||
vjobs := runtime.nr_jobs()
|
vjobs := runtime.nr_jobs()
|
||||||
mut bench := benchmark.new_benchmark()
|
mut bench := benchmark.new_benchmark()
|
||||||
bench.set_total_expected_steps(tasks.len)
|
bench.set_total_expected_steps(tasks.len)
|
||||||
// TODO: close work channel instead of using sentinel items
|
mut work := sync.new_channel<TaskDescription>(tasks.len)
|
||||||
task_sentinel := TaskDescription{
|
|
||||||
path: ''
|
|
||||||
}
|
|
||||||
mut work := sync.new_channel<TaskDescription>(tasks.len + vjobs)
|
|
||||||
mut results := sync.new_channel<TaskDescription>(tasks.len)
|
mut results := sync.new_channel<TaskDescription>(tasks.len)
|
||||||
for i in 0 .. tasks.len {
|
for i in 0 .. tasks.len {
|
||||||
work.push(&tasks[i])
|
work.push(&tasks[i])
|
||||||
}
|
}
|
||||||
|
work.close()
|
||||||
for _ in 0 .. vjobs {
|
for _ in 0 .. vjobs {
|
||||||
work.push(&task_sentinel)
|
|
||||||
go work_processor(mut work, mut results)
|
go work_processor(mut work, mut results)
|
||||||
}
|
}
|
||||||
for _ in 0 .. tasks.len {
|
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) {
|
fn work_processor(mut work sync.Channel, mut results sync.Channel) {
|
||||||
for {
|
for {
|
||||||
mut task := TaskDescription{}
|
mut task := TaskDescription{}
|
||||||
work.pop(&task)
|
if !work.pop(&task) {
|
||||||
if task.path == '' {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
sw := time.new_stopwatch({})
|
sw := time.new_stopwatch({})
|
||||||
|
|
Loading…
Reference in New Issue