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

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 StringBoolMap struct {
mu sync.RWMutex
mu *rwmutex.RWMutex
m map[string]bool
}
func NewStringBoolMap() *StringBoolMap {
func NewStringBoolMap(safe...bool) *StringBoolMap {
return &StringBoolMap{
m: make(map[string]bool),
m : make(map[string]bool),
mu : rwmutex.New(safe...),
}
}