当前位置: 首页>>代码示例>>Golang>>正文


Golang Worker.Kill方法代码示例

本文整理汇总了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()
		}
	}()
}
开发者ID:exekias,项目名称:juju,代码行数:25,代码来源:catacomb.go

示例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)
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:24,代码来源:engine.go

示例3: stopWorker

func stopWorker(w worker.Worker) error {
	w.Kill()
	return w.Wait()
}
开发者ID:exekias,项目名称:juju,代码行数:4,代码来源:machiner_test.go

示例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)
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:check.go

示例5: kill

func kill(w worker.Worker) error {
	w.Kill()
	return w.Wait()
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:4,代码来源:manifold_test.go


注:本文中的github.com/juju/juju/worker.Worker.Kill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。