zieckey / dbuf Goto Github PK
View Code? Open in Web Editor NEWA simple library to manage resources which can be upgraded gracefully
License: Apache License 2.0
A simple library to manage resources which can be upgraded gracefully
License: Apache License 2.0
sync.Map
?采用了一个map
加上mutex
的设计,很奇怪DoubleBufferingManager.Get
获取工作实体对象的时候上锁,DoubleBufferingManager.Add
增加工作实体对象的时候却没有上锁?会不会直接并发读写map
导致fatal
DoubleBuffering.reload
的设计很奇怪,在t.Initialize(conf)
必然已经读取文件进到内存了,content, err := ioutil.ReadFile(conf)
又读取一次文件进到内存,把文件读了两次?第二次读取文件完全没有任何意义,直接取文件名做md5
就可以// DoubleBuffering.reload 重新加载,加载中需要上锁
func (d *DoubleBuffering) reload(conf string) bool {
···
if t.Initialize(conf) == false { // 调用构造函数初始化
return false
}
content, err := ioutil.ReadFile(conf) // 读取文件
if err != nil {
content = []byte(conf)
}
d.md5h = fmt.Sprintf("%x", md5.Sum(content))
···
}
代码看了好久,求指点
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.