// Package easymap... // // Description : 内置sync.Map + segment // // Author : go_developer@163.com<白茶清欢> // // Date : 2021-02-24 2:08 下午 package easymap import ( "sync" ) // NewSegmentSync 获取SegmentSync实例 // // Author : go_developer@163.com<白茶清欢> // // Date : 6:02 下午 2021/2/24 func NewSegmentSync(segment int) (EasyMap, error) { if segment <= 0 { return nil, segmentError() } ss := &segmentSync{ &common{ normalDataTable: nil, syncMapDataTable: nil, dataTableType: syncMapDataTableType, segment: segment, lock: nil, }, } ss.syncMapDataTable = make([]sync.Map, segment) for i := 0; i < segment; i++ { ss.syncMapDataTable[i] = sync.Map{} } ss.initLock() return ss, nil } type segmentSync struct { *common }