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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算