module Concurrent::Promises::FactoryMethods

def any_event(*futures_and_or_events)

Returns:
  • (Future) -
def any_event(*futures_and_or_events)
  any_event_on default_executor, *futures_and_or_events
end

def any_event_on(default_executor, *futures_and_or_events)

Returns:
  • (Event) -

Parameters:
  • futures_and_or_events (AbstractEventFuture) --
def any_event_on(default_executor, *futures_and_or_events)
  AnyResolvedEventPromise.new_blocked_by(futures_and_or_events, default_executor).event
end

def any_fulfilled_future(*futures_and_or_events)

Returns:
  • (Future) -
def any_fulfilled_future(*futures_and_or_events)
  any_fulfilled_future_on default_executor, *futures_and_or_events
end

def any_fulfilled_future_on(default_executor, *futures_and_or_events)

Returns:
  • (Future) -

Parameters:
  • futures_and_or_events (AbstractEventFuture) --
def any_fulfilled_future_on(default_executor, *futures_and_or_events)
  AnyFulfilledFuturePromise.new_blocked_by(futures_and_or_events, default_executor).future
end

def any_resolved_future(*futures_and_or_events)

Returns:
  • (Future) -
def any_resolved_future(*futures_and_or_events)
  any_resolved_future_on default_executor, *futures_and_or_events
end

def any_resolved_future_on(default_executor, *futures_and_or_events)

Returns:
  • (Future) -

Parameters:
  • futures_and_or_events (AbstractEventFuture) --
def any_resolved_future_on(default_executor, *futures_and_or_events)
  AnyResolvedFuturePromise.new_blocked_by(futures_and_or_events, default_executor).future
end

def delay(*args, &task)

Returns:
  • (Future, Event) -
def delay(*args, &task)
  delay_on default_executor, *args, &task
end

def delay_on(default_executor, *args, &task)

Returns:
  • (Event) -
  • (Future) -

Overloads:
  • delay_on(default_executor)
  • delay_on(default_executor, *args, &task)

Other tags:
    Yield: - to the task.
def delay_on(default_executor, *args, &task)
  event = DelayPromise.new(default_executor).event
  task ? event.chain(*args, &task) : event
end

def fulfilled_future(value, default_executor = self.default_executor)

Returns:
  • (Future) -

Parameters:
  • value (Object) --
def fulfilled_future(value, default_executor = self.default_executor)
  resolved_future true, value, nil, default_executor
end

def future(*args, &task)

Returns:
  • (Future) -
def future(*args, &task)
  future_on(default_executor, *args, &task)
end

def future_on(default_executor, *args, &task)

Returns:
  • (Future) -

Other tags:
    Yield: - to the task.
def future_on(default_executor, *args, &task)
  ImmediateEventPromise.new(default_executor).future.then(*args, &task)
end

def make_future(argument = nil, default_executor = self.default_executor)

Returns:
  • (Future) - a fulfilled future with the value.
  • (Future) - a rejected future with the exception as its reason.
  • (Event) - an event which will be resolved when an_event is.
  • (Future) - a future which will be resolved when a_future is.
  • (Event) - resolved event.
  • (Event, Future) -

Parameters:
  • value (Object) -- when none of the above overloads fits
  • exception (Exception) --
  • an_event (Event) --
  • a_future (Future) --
  • nil (nil) --

Overloads:
  • make_future(value, default_executor = self.default_executor)
  • make_future(exception, default_executor = self.default_executor)
  • make_future(an_event, default_executor = self.default_executor)
  • make_future(a_future, default_executor = self.default_executor)
  • make_future(nil, default_executor = self.default_executor)

Other tags:
    See: rejected_future, - resolved_event, fulfilled_future
def make_future(argument = nil, default_executor = self.default_executor)
  case argument
  when AbstractEventFuture
    # returning wrapper would change nothing
    argument
  when Exception
    rejected_future argument, default_executor
  when nil
    resolved_event default_executor
  else
    fulfilled_future argument, default_executor
  end
end

def rejected_future(reason, default_executor = self.default_executor)

Returns:
  • (Future) -

Parameters:
  • reason (Object) --
def rejected_future(reason, default_executor = self.default_executor)
  resolved_future false, nil, reason, default_executor
end

def resolvable_event

Returns:
  • (ResolvableEvent) -
def resolvable_event
  resolvable_event_on default_executor
end

def resolvable_event_on(default_executor = self.default_executor)

Returns:
  • (ResolvableEvent) -
def resolvable_event_on(default_executor = self.default_executor)
  ResolvableEventPromise.new(default_executor).future
end

def resolvable_future

Returns:
  • (ResolvableFuture) -
def resolvable_future
  resolvable_future_on default_executor
end

def resolvable_future_on(default_executor = self.default_executor)

Returns:
  • (ResolvableFuture) -
def resolvable_future_on(default_executor = self.default_executor)
  ResolvableFuturePromise.new(default_executor).future
end

def resolved_event(default_executor = self.default_executor)

Returns:
  • (Event) -
def resolved_event(default_executor = self.default_executor)
  ImmediateEventPromise.new(default_executor).event
end

def resolved_future(fulfilled, value, reason, default_executor = self.default_executor)

Returns:
  • (Future) -

Parameters:
  • reason (Object) --
  • value (Object) --
  • fulfilled (true, false) --
def resolved_future(fulfilled, value, reason, default_executor = self.default_executor)
  ImmediateFuturePromise.new(default_executor, fulfilled, value, reason).future
end

def schedule(intended_time, *args, &task)

Returns:
  • (Future, Event) -
def schedule(intended_time, *args, &task)
  schedule_on default_executor, intended_time, *args, &task
end

def schedule_on(default_executor, intended_time, *args, &task)

Returns:
  • (Event) -
  • (Future) -

Overloads:
  • schedule_on(default_executor, intended_time)
  • schedule_on(default_executor, intended_time, *args, &task)

Other tags:
    Yield: - to the task.

Parameters:
  • intended_time (Numeric, Time) -- `Numeric` means to run in `intended_time` seconds.
def schedule_on(default_executor, intended_time, *args, &task)
  event = ScheduledPromise.new(default_executor, intended_time).event
  task ? event.chain(*args, &task) : event
end

def zip_events(*futures_and_or_events)

Returns:
  • (Event) -
def zip_events(*futures_and_or_events)
  zip_events_on default_executor, *futures_and_or_events
end

def zip_events_on(default_executor, *futures_and_or_events)

Returns:
  • (Event) -

Parameters:
  • futures_and_or_events (AbstractEventFuture) --
def zip_events_on(default_executor, *futures_and_or_events)
  ZipEventsPromise.new_blocked_by(futures_and_or_events, default_executor).event
end

def zip_futures(*futures_and_or_events)

Returns:
  • (Future) -
def zip_futures(*futures_and_or_events)
  zip_futures_on default_executor, *futures_and_or_events
end

def zip_futures_on(default_executor, *futures_and_or_events)

Returns:
  • (Future) -

Parameters:
  • futures_and_or_events (AbstractEventFuture) --
def zip_futures_on(default_executor, *futures_and_or_events)
  ZipFuturesPromise.new_blocked_by(futures_and_or_events, default_executor).future
end