本文整理汇总了Golang中github.com/juju/juju/worker.Worker.Kill方法的典型用法代码示例。如果您正苦于以下问题:Golang Worker.Kill方法的具体用法?Golang Worker.Kill怎么用?Golang Worker.Kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/worker.Worker
的用法示例。
在下文中一共展示了Worker.Kill方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: add
// add starts two goroutines that (1) kill the catacomb's tomb with any
// error encountered by the worker; and (2) kill the worker when the
// catacomb starts dying.
func (catacomb *Catacomb) add(w worker.Worker) {
// The coordination via stopped is not reliably observable, and hence not
// tested, but it's yucky to leave the second goroutine running when we
// don't need to.
stopped := make(chan struct{})
catacomb.wg.Add(1)
go func() {
defer catacomb.wg.Done()
defer close(stopped)
if err := w.Wait(); err != nil {
catacomb.Kill(err)
}
}()
go func() {
select {
case <-stopped:
case <-catacomb.tomb.Dying():
w.Kill()
}
}()
}
示例2: gotStarted
// gotStarted updates the engine to reflect the creation of a worker. It must
// only be called from the loop goroutine.
func (engine *engine) gotStarted(name string, worker worker.Worker) {
// Copy current info; check preconditions and abort the workers if we've
// already been asked to stop it.
info := engine.current[name]
switch {
case info.worker != nil:
engine.tomb.Kill(errors.Errorf("fatal: unexpected %q manifold worker start", name))
fallthrough
case info.stopping, engine.isDying():
logger.Debugf("%q manifold worker no longer required", name)
worker.Kill()
default:
// It's fine to use this worker; update info and copy back.
logger.Infof("%q manifold worker started", name)
info.starting = false
info.worker = worker
engine.current[name] = info
// Any manifold that declares this one as an input needs to be restarted.
engine.bounceDependents(name)
}
}
示例3: stopWorker
func stopWorker(w worker.Worker) error {
w.Kill()
return w.Wait()
}
示例4: CheckKill
// CheckKill Kill()s the supplied worker and Wait()s for its error, which it
// returns for further analysis, or fails the test after a timeout expires.
// It doesn't Assert and is therefore suitable for use from any goroutine.
func CheckKill(c *gc.C, w worker.Worker) error {
w.Kill()
return CheckKilled(c, w)
}
示例5: kill
func kill(w worker.Worker) error {
w.Kill()
return w.Wait()
}