From: qydysky Date: Sat, 13 May 2023 16:17:13 +0000 (+0800) Subject: add X-Git-Tag: v0.26.5~2 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=24e2d50343fb6f34a42abc5fd97c6f5d9112b973;p=part%2F.git add --- diff --git a/msgq/Msgq.go b/msgq/Msgq.go index cbe8ab3..739b8b7 100644 --- a/msgq/Msgq.go +++ b/msgq/Msgq.go @@ -3,6 +3,7 @@ package part import ( "container/list" "context" + "fmt" "runtime" "sync/atomic" "time" @@ -16,6 +17,7 @@ type Msgq struct { funcs *list.List someNeedRemove atomic.Int32 lock sync.RWMutex + runMap sync.Map } type FuncMap map[string]func(any) (disable bool) @@ -132,6 +134,11 @@ type Msgq_tag_data struct { } func (m *Msgq) Push_tag(Tag string, Data any) { + defer func() { + if e := recover(); e != nil { + panic(fmt.Sprintf("Push_tag(%s,%v) > %v", Tag, Data, e)) + } + }() m.Push(Msgq_tag_data{ Tag: Tag, Data: Data, @@ -139,6 +146,11 @@ func (m *Msgq) Push_tag(Tag string, Data any) { } func (m *Msgq) PushLock_tag(Tag string, Data any) { + defer func() { + if e := recover(); e != nil { + panic(fmt.Sprintf("PushLock_tag(%s,%v) > %v", Tag, Data, e)) + } + }() m.PushLock(Msgq_tag_data{ Tag: Tag, Data: Data, @@ -241,6 +253,11 @@ func NewTypeTo[T any](to ...time.Duration) *MsgType[T] { } func (m *MsgType[T]) Push_tag(Tag string, Data T) { + defer func() { + if e := recover(); e != nil { + panic(fmt.Sprintf("Push_tag(%s,%v) > %v", Tag, Data, e)) + } + }() m.m.Push(Msgq_tag_data{ Tag: Tag, Data: Data, @@ -248,6 +265,11 @@ func (m *MsgType[T]) Push_tag(Tag string, Data T) { } func (m *MsgType[T]) PushLock_tag(Tag string, Data T) { + defer func() { + if e := recover(); e != nil { + panic(fmt.Sprintf("PushLock_tag(%s,%v) > %v", Tag, Data, e)) + } + }() m.m.PushLock(Msgq_tag_data{ Tag: Tag, Data: Data, diff --git a/msgq/Msgq_test.go b/msgq/Msgq_test.go index 202bf23..655cdb4 100644 --- a/msgq/Msgq_test.go +++ b/msgq/Msgq_test.go @@ -141,7 +141,7 @@ func BenchmarkXxx(b *testing.B) { func TestPushLock(t *testing.T) { defer func() { - if e := recover(); e.(string) != "timeout to wait rlock, rlc:1" { + if e := recover(); e.(string) != "Push_tag(test,) > PushLock_tag(lock,) > timeout to wait rlock, rlc:1" { t.Fatal(e) } }()