sync.WaitGroup 实现逻辑和源码解析

Posted by 夏泽民

方便的并发,是Golang的一大特色优势,而使用并发,对sync包的WaitGroup不会陌生。WaitGroup主要用来做Golang并发实例即Goroutine的等待,当使用go启动多个并发程序,通过waitgroup可以等待所有go程序结束后再执行后面的代码逻辑,比如: func Main() { wg := sync.WaitGroup{} for i := 0; i < 10; i++ { wg.Add(1) go func() { defer wg.Done() time.Sleep(10 * time.Second) }()



sync.Pool 的设计与实现

Posted by 夏泽民

https://gocn.vip/topics/9921 Go 1.13 版本中有几个比较大的修改,其中之一是sync.Pool修改了部分实现,减小某些极端情况下的性能开销。文中内容来源于笔者读完 sync.Pool 源代码的思考和总结,内容以 Go 1.13 中的实现为准,少量内容涉及到 Go 1.13 之前,如有误区请读者多多指教。



regexp

Posted by 夏泽民

准则



Optimizing a Golang service to reduce over 40% CPU

Posted by 夏泽民

https://coralogix.com/log-analytics-blog/optimizing-a-golang-service-to-reduce-over-40-cpu/



httptest

Posted by 夏泽民

https://golang.org/pkg/net/http/httptest/ https://ieftimov.com/post/testing-in-go-testing-http-servers/ https://ieftimov.com/post/testing-in-go-subtests/



Search

Popular posts

Anything in here will be replaced on browsers that support the canvas element

Recent posts

This blog is maintained by 夏泽民

Get in touch with me at [email protected]

Subscribe to our mailing list

* indicates required