为什么并发红宝石立即退出



我正在尝试使用并发红宝石来执行一些并行任务,我正在遵循文档并使用Concurrent::Async

require 'concurrent'
class Echo
include Concurrent::Async
def echo(msg)
p msg
end
end
horn = Echo.new
horn.async.echo('one')

并在终端中运行它,但进程什么都不打印,并立即退出

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! 

资源代码

最新更新