任务/未来的Ruby

编程入门 行业动态 更新时间:2024-10-13 10:25:29
本文介绍了任务/未来的Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是说重新presents与可能性潜在延迟异步计算订阅其完成图案的惯用红宝石模拟?即沿东西.NET的行 System.Threading.Task 或Python 3.X concurrent.futures.future

What is the idiomatic Ruby analog of a pattern that represents a potentially deferred asynchronous computation with the possibility to subscribe to its completion? i.e. something along the lines of .NET System.Threading.Task, or Python 3.x concurrent.futures.future.

请注意,这并不一定意味着多线程 - 实际执行的未来对象将同样有可能使用调度的工作和取得的结果一些其他的方式,而且是出了问题的范围。该问题涉及严格遵守是psented对象的用户$ P $的API。

Note that this does not necessarily imply multithreading - the actual implementation of the "future" object would just as likely use some other way of scheduling the work and obtaining result, and is out of scope of the question. The question concerns strictly with the API that is presented to the user of the object.

推荐答案

我不知道香草红宝石,但EventMachine的有deferrables.

I am not sure about vanilla Ruby, but EventMachine has deferrables.

此外,检查this文章。

EM.run { detector = LanguageDetector.new("Sgwn i os yw google yn deall Cymraeg?") detector.callback { |lang| puts "The language was #{lang}" } detector.errback { |error| puts "Error: #{error}" } }

更多推荐

任务/未来的Ruby

本文发布于:2023-11-25 02:27:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627951.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未来   Ruby

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!