首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >为什么并发-ruby立即退出

为什么并发-ruby立即退出
EN

Stack Overflow用户
提问于 2019-10-15 02:27:49
回答 1查看 89关注 0票数 0

我正在尝试使用concurrent-ruby来完成一些并行任务,我正在遵循文档并使用Concurrent::Async

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
require 'concurrent'

class Echo
  include Concurrent::Async

  def echo(msg)
    p msg
  end
end

horn = Echo.new
horn.async.echo('one')

并在终端中运行,但进程不打印任何内容,并立即退出

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-16 06:32:48

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
require 'concurrent'

class Echo
  include Concurrent::Async

  def echo(msg)
    p msg
  end
end

horn = Echo.new

# t is an instance of Concurrent::IVar which includes Concurrent::Concern::Obligation
t = horn.async.echo('one')

# wait until obligation is complete or the timeout has been reached
t.wait! 

souce code

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58386397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文