1 Star 0 Fork 0

徐大周的春天/gorose

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
builder_driver.go 797 Bytes
一键复制 编辑 原始数据 按行查看 历史
fizzday 提交于 2019-11-11 11:36 . golint
package gorose
import (
"sync"
)
// BuilderDriver ...
type BuilderDriver struct {
builders map[string]IBuilder
b *sync.Map
}
var builderDriverOnce sync.Once
var builderDriver *BuilderDriver
// NewBuilderDriver ...
func NewBuilderDriver() *BuilderDriver {
builderDriverOnce.Do(func() {
//builderDriver = &BuilderDriver{builders:make(map[string]IBuilder)}
builderDriver = &BuilderDriver{b: &sync.Map{}}
})
return builderDriver
}
// Register ...
func (b *BuilderDriver) Register(driver string, val IBuilder) {
//withLockContext(func() {
// b.builders[driver] = val
//})
b.b.Store(driver, val)
}
// Getter ...
func (b *BuilderDriver) Getter(driver string) IBuilder {
//return b.builders[driver]
if v, ok := (b.b.Load(driver)); ok {
return v.(IBuilder)
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xu_dazhous_spring/gorose.git
git@gitee.com:xu_dazhous_spring/gorose.git
xu_dazhous_spring
gorose
gorose
master

搜索帮助