129

一日一学_Go语言Context(设计及分析) - 简书

 6 years ago
source link: http://www.jianshu.com/p/b7202f2bb477?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
context简单概述: Go服务器的每个请求都有自己的goroutine,而有的请求为了提高性能,会经常启动额外的goroutine处理请求,当该请求被取消或超时,该请求上的所有goroutines应该退出,防止资源泄露。那么context来了,它对该请求上的所有goroutines进行约束,然后进行取消信号,超时等操作。 而context优点就是简洁的管理goroutines的生命周期。...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK