Beispiel #1
0
func (g *Group) run(pid int, runnable func() error) {
	defer func() {
		g.notify <- pid
		if v := recover(); v != nil {
			stackbuf := make([]byte, 16*1024)
			i := runtime.Stack(stackbuf, false)
			stackbuf = stackbuf[:i]
			g.PanicHandler(crash.NewCrashInfo(&crash.CrashData{
				Runnable: runnable,
				PanicVal: v,
				Stack:    stackbuf,
			}))
		}
	}()
	err := g.filterError(runnable())
	if err != nil {
		g.ErrorHandler(crash.NewCrashInfo(&crash.CrashData{
			Runnable: runnable,
			Err:      err,
		}))
		g.Stop()
	}
}
Beispiel #2
0
func (g *Group) syncStop() (closed bool) {
	for {
		closer := g.popCloser()
		if closer == nil {
			break
		} else {
			closed = true
			if err := g.filterError(closer()); err != nil {
				g.ErrorHandler(crash.NewCrashInfo(&crash.CrashData{
					Runnable: closer,
					Err:      err,
				}))
			}
		}
	}
	return closed
}