数据结构容器增加并发安全特性开启/关闭功能,当关闭后和普通的数据结构无异,非并发安全模式下性能会得到提高

This commit is contained in:
john
2018-09-05 18:34:41 +08:00
parent 12bee26d5a
commit ebc10f7779
28 changed files with 278 additions and 126 deletions

View File

@ -8,17 +8,18 @@
package gmap
import (
"sync"
"gitee.com/johng/gf/g/container/internal/rwmutex"
)
type InterfaceInterfaceMap struct {
mu sync.RWMutex
mu *rwmutex.RWMutex
m map[interface{}]interface{}
}
func NewInterfaceInterfaceMap() *InterfaceInterfaceMap {
func NewInterfaceInterfaceMap(safe...bool) *InterfaceInterfaceMap {
return &InterfaceInterfaceMap{
m: make(map[interface{}]interface{}),
m : make(map[interface{}]interface{}),
mu : rwmutex.New(safe...),
}
}