Module: AsyncCable::Util
- Defined in:
- lib/async_cable/util.rb
Class Method Summary collapse
-
.create_task(parent = Async::Task.current?, schedule = false, &block) ⇒ Async::Task
Return created task.
-
.each_async(list, *args) ⇒ Object
Each yield will be executed within it’s own fiber.
Class Method Details
.create_task(parent = Async::Task.current?, schedule = false, &block) ⇒ Async::Task
Return created task.
6 7 8 9 10 11 12 13 14 |
# File 'lib/async_cable/util.rb', line 6 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_async(list, *args) ⇒ Object
Each yield will be executed within it’s own fiber.
19 20 21 22 23 |
# File 'lib/async_cable/util.rb', line 19 def each_async(list, *args) list.each do |item| create_task(*args) { yield item } end end |