1 Star 0 Fork 0

magicianlyx/GoLog

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cbfunc.go 650 Bytes
一键复制 编辑 原始数据 按行查看 历史
magicianlyx 提交于 2022-01-24 17:45 +08:00 . -
package GoLog
import (
"reflect"
"sync"
)
type CbFuncMap struct {
fMap sync.Map
}
func NewCbFuncMap() *CbFuncMap {
return &CbFuncMap{sync.Map{}}
}
func (fm *CbFuncMap) Add(i interface{}) {
p := reflect.ValueOf(i).Pointer()
fm.fMap.Store(p, i)
}
func (fm *CbFuncMap) Del(i interface{}) {
p := reflect.ValueOf(i).Pointer()
fm.fMap.Delete(p)
}
func (fm *CbFuncMap) GetAll(out interface{}) int {
ro := reflect.ValueOf(out).Elem()
eo := make([]reflect.Value, 0)
n := 0
fm.fMap.Range(func(key, value interface{}) bool {
n += 1
eo = append(eo, reflect.ValueOf(value))
return true
})
ro.Set(reflect.Append(ro, eo...))
return n
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/magicianlyx/GoLog.git
git@gitee.com:magicianlyx/GoLog.git
magicianlyx
GoLog
GoLog
20c45f9b998d

搜索帮助