if ctx is nil, set it to background context

This commit is contained in:
adman
2026-05-10 14:30:28 +02:00
parent b5ee17d1ae
commit c483bf9553
+3
View File
@@ -240,6 +240,9 @@ func NewLoop() (l *Loop) {
} }
func NewLoopCtx(ctx context.Context) (l *Loop) { func NewLoopCtx(ctx context.Context) (l *Loop) {
if ctx == nil {
ctx = context.Background()
}
l = &Loop{} l = &Loop{}
l.Ctx, l.Cancel = context.WithCancel(ctx) l.Ctx, l.Cancel = context.WithCancel(ctx)
l.HandlerFunctions = make(map[reflect.Type][]reflect.Value) l.HandlerFunctions = make(map[reflect.Type][]reflect.Value)