module Concurrent::Async

def async

Other tags:
    See: Concurrent::Future -

Raises:
  • (ArgumentError) - the given `args` do not match the arity of `method`
  • (NameError) - the object does not respond to `method` method

Returns:
  • (Concurrent::Future) - the pending result of the asynchronous operation

Other tags:
    Note: - The method call is guaranteed to be thread safe with respect to
def async
  @__async_delegator__ ||= AsyncDelegator.new(self, executor, await.mutex)
end

def await

Other tags:
    See: Concurrent::IVar -

Raises:
  • (ArgumentError) - the given `args` do not match the arity of `method`
  • (NameError) - the object does not respond to `method` method

Returns:
  • (Concurrent::IVar) - the completed result of the synchronous operation

Other tags:
    Note: - The method call is guaranteed to be thread safe with respect to
def await
  @__await_delegator__ ||= AwaitDelegator.new(self, Mutex.new)
end

def executor

def executor
  @__async__executor__ ||= Concurrent.configuration.global_task_pool
end

def executor=(executor)

def executor=(executor)
  raise ArgumentError.new('executor has already been set') unless @__async__executor__.nil?
  @__async__executor__ = executor
end

def validate_argc(obj, method, *args)

Other tags:
    See: http://www.ruby-doc.org/core-2.1.0/BasicObject.html#method-i-method_missing - BasicObject#method_missing
    See: http://ruby-doc.org/core-2.1.0/Object.html#method-i-respond_to-3F - Object#respond_to?
    See: http://www.ruby-doc.org/core-2.1.1/Method.html#method-i-arity - Method#arity

Other tags:
    Note: - This check is imperfect because of the way Ruby reports the arity of

Raises:
  • (ArgumentError) - the given `args` do not match the arity of `method`
  • (NameError) - the object does not respond to `method` method

Parameters:
  • args (Array) -- zero or more arguments for the arity check
  • method (Symbol) -- the method to check the object for
  • obj (Object) -- the object to check against
def validate_argc(obj, method, *args)
  argc = args.length
  arity = obj.method(method).arity
  if arity >= 0 && argc != arity
    raise ArgumentError.new("wrong number of arguments (#{argc} for #{arity})")
  elsif arity < 0 && (arity = (arity + 1).abs) > argc
    raise ArgumentError.new("wrong number of arguments (#{argc} for #{arity}..*)")
  end
end