异步::IO
Async::IO 提供基于构建,并为IO 、 Socket和相关类提供异步包装器。
安装
将此行添加到应用程序的 Gemfile 中:
gem 'async-io'
然后执行:
$ bundle
或者自己安装:
$ gem install async-io
用法
基本回显服务器(来自spec/async/io/echo_spec.rb ):
require 'async/io'
def echo_server ( endpoint )
Async do | task |
# This is a synchronous block within the current task:
endpoint . accept do | client |
# This is an asynchronous block within th
1