MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / OnKey

Function OnKey

internal/events/utils.go:39–53  ·  view source on GitHub ↗

OnKey 使用Key增加事件回调

(event Event, key interface{}, callback func())

Source from the content-addressed store, hash-verified

37
38// OnKey 使用Key增加事件回调
39func OnKey(event Event, key interface{}, callback func()) {
40 if key == nil {
41 key = NewKey()
42 }
43
44 locker.Lock()
45 defer locker.Unlock()
46
47 m, ok := eventsMap[event]
48 if !ok {
49 m = map[interface{}]Callbacks{}
50 eventsMap[event] = m
51 }
52 m[key] = append(m[key], callback)
53}
54
55// Remove 删除事件回调
56func Remove(key interface{}) {

Callers 12

NewDBFunction · 0.92
initListMethod · 0.92
listenTCPMethod · 0.92
listenUDPMethod · 0.92
ListenMethod · 0.92
startSyncTimerMethod · 0.92
listenSockMethod · 0.92
StartMethod · 0.92
TestOnFunction · 0.92
StartMethod · 0.92
StartMethod · 0.92
OnFunction · 0.85

Calls 3

NewKeyFunction · 0.85
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1

TestOnFunction · 0.74