本文整理匯總了Golang中launchpad/net/tomb.Tomb.Kill方法的典型用法代碼示例。如果您正苦於以下問題:Golang Tomb.Kill方法的具體用法?Golang Tomb.Kill怎麽用?Golang Tomb.Kill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類launchpad/net/tomb.Tomb
的用法示例。
在下文中一共展示了Tomb.Kill方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Stop
// Stop stops the watcher. If an error is returned by the
// watcher, t is killed with the error.
func Stop(w Stopper, t *tomb.Tomb) {
if err := w.Stop(); err != nil {
if err != tomb.ErrStillAlive && err != tomb.ErrDying {
// tomb.Kill() checks for the two errors above
// by value, so we shouldn't wrap them, but we
// wrap any other error.
err = errors.Trace(err)
}
t.Kill(err)
}
}
示例2: delayedTomb
// delayedTomb returns a tomb that starts dying a given duration
// after t starts dying.
func delayedTomb(t *tomb.Tomb, d time.Duration) *tomb.Tomb {
var delayed tomb.Tomb
go func() {
select {
case <-t.Dying():
time.Sleep(d)
delayed.Kill(nil)
case <-delayed.Dying():
return
}
}()
return &delayed
}
示例3: propagateTearDown
// propagateTearDown tears down the handler, but ensures any error is
// propagated through the tomb's Kill method.
func propagateTearDown(handler tearDowner, t *tomb.Tomb) {
if err := handler.TearDown(); err != nil {
t.Kill(err)
}
}
示例4: Stop
// Stop stops the watcher. If an error is returned by the
// watcher, t is killed with the error.
func Stop(w Stopper, t *tomb.Tomb) {
if err := w.Stop(); err != nil {
t.Kill(err)
}
}
示例5: handlerTearDown
// TearDown the handler, but ensure any error is propagated
func handlerTearDown(handler WatchHandler, t *tomb.Tomb) {
if err := handler.TearDown(); err != nil {
t.Kill(err)
}
}