module Elixir::Task

Constants

POOL

Public Instance Methods

async(fun) click to toggle source
# File lib/elixir/task.rb, line 10
def async fun
  fun.extend Concurrent::Async
  fun.init_mutex

  fun.async.call
end
await(task, timeout = 5000) click to toggle source
# File lib/elixir/task.rb, line 17
def await task, timeout = 5000
  value = task.value timeout / 1000
  task.fail && raise(StandardError, 'time out') if task.pending?

  value
end
start(fun) click to toggle source
# File lib/elixir/task.rb, line 24
def start fun
  POOL << fun
end