當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。