Skip to content

Commit 134c047

Browse files
committed
client/ar: remove useless wait ch from runTasks
Arguably this makes task.WaitCh() useless, but I think exposing a wait chan from TaskRunners is a generically useful API.
1 parent 021c0cc commit 134c047

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

client/allocrunner/alloc_runner.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ func (ar *allocRunner) Run() {
213213
goto POST
214214
}
215215

216-
// Run the runners and block until they exit
217-
<-ar.runTasks()
216+
// Run the runners (blocks until they exit)
217+
ar.runTasks()
218218

219219
POST:
220220
// Run the postrun hooks
@@ -249,23 +249,15 @@ func (ar *allocRunner) shouldRun() bool {
249249
return true
250250
}
251251

252-
// runTasks is used to run the task runners.
253-
func (ar *allocRunner) runTasks() <-chan struct{} {
252+
// runTasks is used to run the task runners and block until they exit.
253+
func (ar *allocRunner) runTasks() {
254254
for _, task := range ar.tasks {
255255
go task.Run()
256256
}
257257

258-
// Return a combined WaitCh that is closed when all task runners have
259-
// exited.
260-
waitCh := make(chan struct{})
261-
go func() {
262-
defer close(waitCh)
263-
for _, task := range ar.tasks {
264-
<-task.WaitCh()
265-
}
266-
}()
267-
268-
return waitCh
258+
for _, task := range ar.tasks {
259+
<-task.WaitCh()
260+
}
269261
}
270262

271263
// Alloc returns the current allocation being run by this runner as sent by the

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy