Sha256: c5aeee2e67efe2896c7adbe3fdd6f9343b8f53666f722da5ebe3e80ed8fa0375
Contents?: true
Size: 855 Bytes
Versions: 4
Compression:
Stored size: 855 Bytes
Contents
module AsyncCable module Util # @param parent [Async::Task,NilClass] parent task for new one. # @param schedule [Boolean] run now if true, otherwise will be run at next reactor loop cycle. # @return [Async::Task] return created task. def create_task(parent = Async::Task.current?, schedule = false, &block) task = Async::Task.new(parent, &block) if schedule Async::Task.current.reactor << task.fiber else task.run end task end # Each yield will be executed within it's own fiber. # @param list [Array] list that will be iterable. # @param args [Array] parent, schedule @see #create_task (optional). def each_async(list, *args) list.each do |item| create_task(*args) { yield item } end end module_function :create_task, :each_async end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
async_cable-0.2.3 | lib/async_cable/util.rb |
async_cable-0.2.2 | lib/async_cable/util.rb |
async_cable-0.2.1 | lib/async_cable/util.rb |
async_cable-0.2.0 | lib/async_cable/util.rb |