本文整理汇总了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)
}
}