Sha256: 1e2bdc4425995072d1e5762bc9c1211525e4da21561b120acc0e02b9b1c226bd
Contents?: true
Size: 483 Bytes
Versions: 4
Compression:
Stored size: 483 Bytes
Contents
require_relative '../lib/async/await' class << self include Async::Await async def sort_one(item, into) sleep(item.to_f) into << item puts "I've sorted #{item} for you." end async def sort(items) result = [] items.each do |item| sort_one(item, result) end # Wait until all previous async method calls have finished executing. barrier! return result end end puts "Hold on, sorting..." puts sort([5, 2, 3, 4, 9, 2, 5, 7, 8]).result.inspect
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
async-await-0.5.0 | examples/sleep_sort.rb |
async-await-0.4.0 | examples/sleep_sort.rb |
async-await-0.3.0 | examples/sleep_sort.rb |
async-await-0.2.0 | examples/sleep_sort.rb |