Coming soon

Coming soon

This is 林尽欢, a brand new site by LeslieLin that's just getting started. Things will be up and running here shortly, but you can subscribe in the meantime if you'd like to stay up to date and receive emails when new content is published!

Read more

深入浅出 Go Context

深入浅出 Go Context

在 Go中,最重要的一个概念就是并发协程,它只需用一个关键字go就可以开启一个协程并运行。在并发协程中,由于超时、取消操作或者一些异常情况,往往需要进行抢占操作或者中断后续操作,比如在实际中当服务器端收到一个请求时,很可能需要发送几个请求去请求其他服务的数据,由于Go语法上的同步阻塞写法,我们一般会创建几个goroutine并发去做一些事情;那么这时候很可能几个goroutine之间需要共享数据,还有当request被取消时,创建的几个goroutine也应该被取消掉,那么这就是context的用武之地。

By LeslieLin