duanchu2607 2018-04-22 08:56
浏览 25
已采纳

跨流程传递截止日期和取消信号

The golang context documentation says :

Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.

I also read concrete examples of context, but I don't see any information on carring deadlines and cancellation signals across processes.

How does signals work across processes?

Are they reliable like, if service1 sends a cancel signal but it dies, and signal is lost, what happens now?

  • 写回答

1条回答 默认 最新

  • doujubeng2942 2018-04-22 10:30
    关注

    Sorry to break your enthusiasm, but the context package cannot be used as-is for inter-process communication and signaling.

    The wording here may be a little imperfect, as in the "context" of the context package documentation most people would think of "processes" as an OS process entity. But the word "process" has multiple meanings, and the more general "a set of activities that interact to achieve a result" meaning is used here (from Wikipedia: Process). To avoid ambiguity, "goroutines" or "a set of goroutines" would be more appropriate here, but within the same Go application.

    Note that when the context package was first published as a separate, experimental package (not as part of the standard library), this blog post explained its background and uses: Go Concurrency Patterns: Context. The context haven't change since it was integrated into the standard library, and that blog post did not mention the word "process", not even once.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计