何小豆儿在此 发表于 2022-8-12 07:06:24

Contex包了解一下

Context包了解一下

为啥需要Context

​                在并发编程中,由于超时、取消操作或者一些异常情况,往往需要进行抢占操作或者中断后续操作,context营运而生,channel也能用但是层级太深了的话channel就不好用了。
Context接口

type Context interface {    Deadline() (deadline time.Time, ok bool)    Done()
页: [1]
查看完整版本: Contex包了解一下