2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-11-05 23:29:53 +00:00
|
|
|
|
2015-11-10 22:24:34 +00:00
|
|
|
import (
|
2016-02-17 18:55:54 +00:00
|
|
|
"sync"
|
2015-11-10 22:57:10 +00:00
|
|
|
|
2015-12-01 19:56:08 +00:00
|
|
|
"github.com/docker/containerd/runtime"
|
2015-11-10 22:24:34 +00:00
|
|
|
)
|
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
// StartResponse is the response containing a started container
|
2015-12-16 00:22:53 +00:00
|
|
|
type StartResponse struct {
|
2016-02-11 19:56:11 +00:00
|
|
|
Container runtime.Container
|
2015-12-16 00:22:53 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
// Task executes an action returning an error chan with either nil or
|
|
|
|
// the error from executing the task
|
|
|
|
type Task interface {
|
|
|
|
// ErrorCh returns a channel used to report and error from an async task
|
|
|
|
ErrorCh() chan error
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
2015-12-16 21:53:11 +00:00
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
type baseTask struct {
|
|
|
|
errCh chan error
|
|
|
|
mu sync.Mutex
|
2015-12-16 21:53:11 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
func (t *baseTask) ErrorCh() chan error {
|
|
|
|
t.mu.Lock()
|
|
|
|
defer t.mu.Unlock()
|
|
|
|
if t.errCh == nil {
|
|
|
|
t.errCh = make(chan error, 1)
|
2015-12-16 21:53:11 +00:00
|
|
|
}
|
2016-02-17 18:55:54 +00:00
|
|
|
return t.errCh
|
2015-12-16 21:53:11 +00:00
|
|
|
}
|