code
stringlengths 26
124k
| docstring
stringlengths 23
125k
| func_name
stringlengths 1
98
| language
stringclasses 1
value | repo
stringlengths 5
53
| path
stringlengths 7
151
| url
stringlengths 50
211
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
def set(value = NULL, &block)
raise PromiseExecutionError.new('supported only on root promise') unless root?
check_for_block_or_value!(block_given?, value)
synchronize do
if @state != :unscheduled
raise MultipleAssignmentError
else
@promise_body = block || Proc.new { |result| value }
end
end
execute
end | @!macro ivar_set_method
@raise [Concurrent::PromiseExecutionError] if not the root promise | set | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | Apache-2.0 |
def fail(reason = StandardError.new)
set { raise reason }
end | @!macro ivar_fail_method
@raise [Concurrent::PromiseExecutionError] if not the root promise | fail | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | Apache-2.0 |
def then(*args, &block)
if args.last.is_a?(::Hash)
executor = args.pop[:executor]
rescuer = args.first
else
rescuer, executor = args
end
executor ||= @executor
raise ArgumentError.new('rescuers and block are both missing') if rescuer.nil? && !block_given?
block = Proc.new { |result| result } unless block_given?
child = Promise.new(
parent: self,
executor: executor,
on_fulfill: block,
on_reject: rescuer
)
synchronize do
child.state = :pending if @state == :pending
child.on_fulfill(apply_deref_options(@value)) if @state == :fulfilled
child.on_reject(@reason) if @state == :rejected
@children << child
end
child
end | Chain a new promise off the current promise.
@return [Promise] the new promise
@yield The block operation to be performed asynchronously.
@overload then(rescuer, executor, &block)
@param [Proc] rescuer An optional rescue block to be executed if the
promise is rejected.
@param [ThreadPool] executor An optional thread pool executor to be used
in the new Promise
@overload then(rescuer, executor: executor, &block)
@param [Proc] rescuer An optional rescue block to be executed if the
promise is rejected.
@param [ThreadPool] executor An optional thread pool executor to be used
in the new Promise | then | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | Apache-2.0 |
def on_success(&block)
raise ArgumentError.new('no block given') unless block_given?
self.then(&block)
end | Chain onto this promise an action to be undertaken on success
(fulfillment).
@yield The block to execute
@return [Promise] self | on_success | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | Apache-2.0 |
def flat_map(&block)
child = Promise.new(
parent: self,
executor: ImmediateExecutor.new,
)
on_error { |e| child.on_reject(e) }
on_success do |result1|
begin
inner = block.call(result1)
inner.execute
inner.on_success { |result2| child.on_fulfill(result2) }
inner.on_error { |e| child.on_reject(e) }
rescue => e
child.on_reject(e)
end
end
child
end | Yield the successful result to the block that returns a promise. If that
promise is also successful the result is the result of the yielded promise.
If either part fails the whole also fails.
@example
Promise.execute { 1 }.flat_map { |v| Promise.execute { v + 2 } }.value! #=> 3
@return [Promise] | flat_map | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | Apache-2.0 |
def zip(*others)
self.class.zip(self, *others)
end | Builds a promise that produces the result of self and others in an Array
and fails if any of them fails.
@overload zip(*promises)
@param [Array<Promise>] others
@overload zip(*promises, opts)
@param [Array<Promise>] others
@param [Hash] opts the configuration options
@option opts [Executor] :executor (ImmediateExecutor.new) when set use the given `Executor` instance.
@option opts [Boolean] :execute (true) execute promise before returning
@return [Promise<Array>] | zip | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb | Apache-2.0 |
def resolvable_event
resolvable_event_on default_executor
end | @!macro promises.shortcut.on
@return [ResolvableEvent] | resolvable_event | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def resolvable_future
resolvable_future_on default_executor
end | @!macro promises.shortcut.on
@return [ResolvableFuture] | resolvable_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def future(*args, &task)
future_on(default_executor, *args, &task)
end | @!macro promises.shortcut.on
@return [Future] | future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def future_on(default_executor, *args, &task)
ImmediateEventPromise.new(default_executor).future.then(*args, &task)
end | Constructs new Future which will be resolved after block is evaluated on default executor.
Evaluation begins immediately.
@!macro promises.param.default_executor
@!macro promises.param.args
@yield [*args] to the task.
@!macro promise.param.task-future
@return [Future] | future_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def resolved_future(fulfilled, value, reason, default_executor = self.default_executor)
ImmediateFuturePromise.new(default_executor, fulfilled, value, reason).future
end | Creates resolved future with will be either fulfilled with the given value or rejection with
the given reason.
@param [true, false] fulfilled
@param [Object] value
@param [Object] reason
@!macro promises.param.default_executor
@return [Future] | resolved_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def fulfilled_future(value, default_executor = self.default_executor)
resolved_future true, value, nil, default_executor
end | Creates resolved future with will be fulfilled with the given value.
@!macro promises.param.default_executor
@param [Object] value
@return [Future] | fulfilled_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def rejected_future(reason, default_executor = self.default_executor)
resolved_future false, nil, reason, default_executor
end | Creates resolved future with will be rejected with the given reason.
@!macro promises.param.default_executor
@param [Object] reason
@return [Future] | rejected_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
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 | General constructor. Behaves differently based on the argument's type. It's provided for convenience
but it's better to be explicit.
@see rejected_future, resolved_event, fulfilled_future
@!macro promises.param.default_executor
@return [Event, Future]
@overload make_future(nil, default_executor = self.default_executor)
@param [nil] nil
@return [Event] resolved event.
@overload make_future(a_future, default_executor = self.default_executor)
@param [Future] a_future
@return [Future] a future which will be resolved when a_future is.
@overload make_future(an_event, default_executor = self.default_executor)
@param [Event] an_event
@return [Event] an event which will be resolved when an_event is.
@overload make_future(exception, default_executor = self.default_executor)
@param [Exception] exception
@return [Future] a rejected future with the exception as its reason.
@overload make_future(value, default_executor = self.default_executor)
@param [Object] value when none of the above overloads fits
@return [Future] a fulfilled future with the value. | make_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def delay(*args, &task)
delay_on default_executor, *args, &task
end | @!macro promises.shortcut.on
@return [Future, Event] | delay | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def delay_on(default_executor, *args, &task)
event = DelayPromise.new(default_executor).event
task ? event.chain(*args, &task) : event
end | Creates new event or future which is resolved only after it is touched,
see {Concurrent::AbstractEventFuture#touch}.
@!macro promises.param.default_executor
@overload delay_on(default_executor, *args, &task)
If task is provided it returns a {Future} representing the result of the task.
@!macro promises.param.args
@yield [*args] to the task.
@!macro promise.param.task-future
@return [Future]
@overload delay_on(default_executor)
If no task is provided, it returns an {Event}
@return [Event] | delay_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def schedule(intended_time, *args, &task)
schedule_on default_executor, intended_time, *args, &task
end | @!macro promises.shortcut.on
@return [Future, Event] | schedule | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def schedule_on(default_executor, intended_time, *args, &task)
event = ScheduledPromise.new(default_executor, intended_time).event
task ? event.chain(*args, &task) : event
end | Creates new event or future which is resolved in intended_time.
@!macro promises.param.default_executor
@!macro promises.param.intended_time
@param [Numeric, Time] intended_time `Numeric` means to run in `intended_time` seconds.
`Time` means to run on `intended_time`.
@overload schedule_on(default_executor, intended_time, *args, &task)
If task is provided it returns a {Future} representing the result of the task.
@!macro promises.param.args
@yield [*args] to the task.
@!macro promise.param.task-future
@return [Future]
@overload schedule_on(default_executor, intended_time)
If no task is provided, it returns an {Event}
@return [Event] | schedule_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def zip_futures(*futures_and_or_events)
zip_futures_on default_executor, *futures_and_or_events
end | @!macro promises.shortcut.on
@return [Future] | zip_futures | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def zip_futures_on(default_executor, *futures_and_or_events)
ZipFuturesPromise.new_blocked_by(futures_and_or_events, default_executor).future
end | Creates new future which is resolved after all futures_and_or_events are resolved.
Its value is array of zipped future values. Its reason is array of reasons for rejection.
If there is an error it rejects.
@!macro promises.event-conversion
If event is supplied, which does not have value and can be only resolved, it's
represented as `:fulfilled` with value `nil`.
@!macro promises.param.default_executor
@param [AbstractEventFuture] futures_and_or_events
@return [Future] | zip_futures_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def zip_events(*futures_and_or_events)
zip_events_on default_executor, *futures_and_or_events
end | @!macro promises.shortcut.on
@return [Event] | zip_events | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def zip_events_on(default_executor, *futures_and_or_events)
ZipEventsPromise.new_blocked_by(futures_and_or_events, default_executor).event
end | Creates new event which is resolved after all futures_and_or_events are resolved.
(Future is resolved when fulfilled or rejected.)
@!macro promises.param.default_executor
@param [AbstractEventFuture] futures_and_or_events
@return [Event] | zip_events_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any_resolved_future(*futures_and_or_events)
any_resolved_future_on default_executor, *futures_and_or_events
end | @!macro promises.shortcut.on
@return [Future] | any_resolved_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any_resolved_future_on(default_executor, *futures_and_or_events)
AnyResolvedFuturePromise.new_blocked_by(futures_and_or_events, default_executor).future
end | Creates new future which is resolved after first futures_and_or_events is resolved.
Its result equals result of the first resolved future.
@!macro promises.any-touch
If resolved it does not propagate {Concurrent::AbstractEventFuture#touch}, leaving delayed
futures un-executed if they are not required any more.
@!macro promises.event-conversion
@!macro promises.param.default_executor
@param [AbstractEventFuture] futures_and_or_events
@return [Future] | any_resolved_future_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any_fulfilled_future(*futures_and_or_events)
any_fulfilled_future_on default_executor, *futures_and_or_events
end | @!macro promises.shortcut.on
@return [Future] | any_fulfilled_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any_fulfilled_future_on(default_executor, *futures_and_or_events)
AnyFulfilledFuturePromise.new_blocked_by(futures_and_or_events, default_executor).future
end | Creates new future which is resolved after first of futures_and_or_events is fulfilled.
Its result equals result of the first resolved future or if all futures_and_or_events reject,
it has reason of the last resolved future.
@!macro promises.any-touch
@!macro promises.event-conversion
@!macro promises.param.default_executor
@param [AbstractEventFuture] futures_and_or_events
@return [Future] | any_fulfilled_future_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any_event(*futures_and_or_events)
any_event_on default_executor, *futures_and_or_events
end | @!macro promises.shortcut.on
@return [Event] | any_event | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any_event_on(default_executor, *futures_and_or_events)
AnyResolvedEventPromise.new_blocked_by(futures_and_or_events, default_executor).event
end | Creates new event which becomes resolved after first of the futures_and_or_events resolves.
@!macro promises.any-touch
@!macro promises.param.default_executor
@param [AbstractEventFuture] futures_and_or_events
@return [Event] | any_event_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def touch
@Promise.touch
self
end | Propagates touch. Requests all the delayed futures, which it depends on, to be
executed. This method is called by any other method requiring resolved state, like {#wait}.
@return [self] | touch | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def wait(timeout = nil)
result = wait_until_resolved(timeout)
timeout ? result : self
end | @!macro promises.touches
Calls {Concurrent::AbstractEventFuture#touch}.
@!macro promises.method.wait
Wait (block the Thread) until receiver is {#resolved?}.
@!macro promises.touches
@!macro promises.warn.blocks
@!macro promises.param.timeout
@return [self, true, false] self implies timeout was not used, true implies timeout was used
and it was resolved, false implies it was not resolved within timeout. | wait | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def chain(*args, &task)
chain_on @DefaultExecutor, *args, &task
end | @!macro promises.shortcut.on
@return [Future] | chain | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def chain_on(executor, *args, &task)
ChainPromise.new_blocked_by1(self, @DefaultExecutor, executor, args, &task).future
end | Chains the task to be executed asynchronously on executor after it is resolved.
@!macro promises.param.executor
@!macro promises.param.args
@return [Future]
@!macro promise.param.task-future
@overload an_event.chain_on(executor, *args, &task)
@yield [*args] to the task.
@overload a_future.chain_on(executor, *args, &task)
@yield [fulfilled, value, reason, *args] to the task.
@yieldparam [true, false] fulfilled
@yieldparam [Object] value
@yieldparam [Object] reason | chain_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def chain_resolvable(resolvable)
on_resolution! { resolvable.resolve_with internal_state }
end | Resolves the resolvable when receiver is resolved.
@param [Resolvable] resolvable
@return [self] | chain_resolvable | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_resolution(*args, &callback)
on_resolution_using @DefaultExecutor, *args, &callback
end | @!macro promises.shortcut.using
@return [self] | on_resolution | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_resolution!(*args, &callback)
add_callback :callback_on_resolution, args, callback
end | Stores the callback to be executed synchronously on resolving thread after it is
resolved.
@!macro promises.param.args
@!macro promise.param.callback
@return [self]
@overload an_event.on_resolution!(*args, &callback)
@yield [*args] to the callback.
@overload a_future.on_resolution!(*args, &callback)
@yield [fulfilled, value, reason, *args] to the callback.
@yieldparam [true, false] fulfilled
@yieldparam [Object] value
@yieldparam [Object] reason | on_resolution! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_resolution_using(executor, *args, &callback)
add_callback :async_callback_on_resolution, executor, args, callback
end | Stores the callback to be executed asynchronously on executor after it is resolved.
@!macro promises.param.executor
@!macro promises.param.args
@!macro promise.param.callback
@return [self]
@overload an_event.on_resolution_using(executor, *args, &callback)
@yield [*args] to the callback.
@overload a_future.on_resolution_using(executor, *args, &callback)
@yield [fulfilled, value, reason, *args] to the callback.
@yieldparam [true, false] fulfilled
@yieldparam [Object] value
@yieldparam [Object] reason | on_resolution_using | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def with_default_executor(executor)
raise NotImplementedError
end | @!macro promises.method.with_default_executor
Crates new object with same class with the executor set as its new default executor.
Any futures depending on it will use the new default executor.
@!macro promises.shortcut.event-future
@abstract
@return [AbstractEventFuture] | with_default_executor | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def blocks
@Callbacks.each_with_object([]) do |(method, args), promises|
promises.push(args[0]) if method == :callback_notify_blocked
end
end | For inspection.
@!visibility private
@return [Array<AbstractPromise>] | blocks | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def zip(other)
if other.is_a?(Future)
ZipFutureEventPromise.new_blocked_by2(other, self, @DefaultExecutor).future
else
ZipEventEventPromise.new_blocked_by2(self, other, @DefaultExecutor).event
end
end | @!macro promises.method.zip
Creates a new event or a future which will be resolved when receiver and other are.
Returns an event if receiver and other are events, otherwise returns a future.
If just one of the parties is Future then the result
of the returned future is equal to the result of the supplied future. If both are futures
then the result is as described in {FactoryMethods#zip_futures_on}.
@return [Future, Event] | zip | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any(event_or_future)
AnyResolvedEventPromise.new_blocked_by2(self, event_or_future, @DefaultExecutor).event
end | Creates a new event which will be resolved when the first of receiver, `event_or_future`
resolves.
@return [Event] | any | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def delay
event = DelayPromise.new(@DefaultExecutor).event
ZipEventEventPromise.new_blocked_by2(self, event, @DefaultExecutor).event
end | Creates new event dependent on receiver which will not evaluate until touched, see {#touch}.
In other words, it inserts delay into the chain of Futures making rest of it lazy evaluated.
@return [Event] | delay | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def schedule(intended_time)
chain do
event = ScheduledPromise.new(@DefaultExecutor, intended_time).event
ZipEventEventPromise.new_blocked_by2(self, event, @DefaultExecutor).event
end.flat_event
end | @!macro promise.method.schedule
Creates new event dependent on receiver scheduled to execute on/in intended_time.
In time is interpreted from the moment the receiver is resolved, therefore it inserts
delay into the chain.
@!macro promises.param.intended_time
@return [Event] | schedule | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def to_future
future = Promises.resolvable_future
ensure
chain_resolvable(future)
end | Converts event to a future. The future is fulfilled when the event is resolved, the future may never fail.
@return [Future] | to_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def fulfilled?
state = internal_state
state.resolved? && state.fulfilled?
end | Is it in fulfilled state?
@return [Boolean] | fulfilled? | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def rejected?
state = internal_state
state.resolved? && !state.fulfilled?
end | Is it in rejected state?
@return [Boolean] | rejected? | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def value(timeout = nil, timeout_value = nil)
if wait_until_resolved timeout
internal_state.value
else
timeout_value
end
end | @!macro promises.warn.nil
@note Make sure returned `nil` is not confused with timeout, no value when rejected,
no reason when fulfilled, etc.
Use more exact methods if needed, like {#wait}, {#value!}, {#result}, etc.
@!macro promises.method.value
Return value of the future.
@!macro promises.touches
@!macro promises.warn.blocks
@!macro promises.warn.nil
@!macro promises.param.timeout
@!macro promises.param.timeout_value
@param [Object] timeout_value a value returned by the method when it times out
@return [Object, nil, timeout_value] the value of the Future when fulfilled,
timeout_value on timeout,
nil on rejection. | value | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def reason(timeout = nil, timeout_value = nil)
if wait_until_resolved timeout
internal_state.reason
else
timeout_value
end
end | Returns reason of future's rejection.
@!macro promises.touches
@!macro promises.warn.blocks
@!macro promises.warn.nil
@!macro promises.param.timeout
@!macro promises.param.timeout_value
@return [Object, timeout_value] the reason, or timeout_value on timeout, or nil on fulfillment. | reason | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def result(timeout = nil)
internal_state.result if wait_until_resolved timeout
end | Returns triplet fulfilled?, value, reason.
@!macro promises.touches
@!macro promises.warn.blocks
@!macro promises.param.timeout
@return [Array(Boolean, Object, Object), nil] triplet of fulfilled?, value, reason, or nil
on timeout. | result | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def wait!(timeout = nil)
result = wait_until_resolved!(timeout)
timeout ? result : self
end | @!macro promises.method.wait
@raise [Exception] {#reason} on rejection | wait! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def value!(timeout = nil, timeout_value = nil)
if wait_until_resolved! timeout
internal_state.value
else
timeout_value
end
end | @!macro promises.method.value
@return [Object, nil, timeout_value] the value of the Future when fulfilled,
or nil on rejection,
or timeout_value on timeout.
@raise [Exception] {#reason} on rejection | value! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def exception(*args)
raise Concurrent::Error, 'it is not rejected' unless rejected?
raise ArgumentError unless args.size <= 1
reason = Array(internal_state.reason).flatten.compact
if reason.size > 1
ex = Concurrent::MultipleErrors.new reason
ex.set_backtrace(caller)
ex
else
ex = if reason[0].respond_to? :exception
reason[0].exception(*args)
else
RuntimeError.new(reason[0]).exception(*args)
end
ex.set_backtrace Array(ex.backtrace) + caller
ex
end
end | Allows rejected Future to be risen with `raise` method.
If the reason is not an exception `Runtime.new(reason)` is returned.
@example
raise Promises.rejected_future(StandardError.new("boom"))
raise Promises.rejected_future("or just boom")
@raise [Concurrent::Error] when raising not rejected future
@return [Exception] | exception | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def then(*args, &task)
then_on @DefaultExecutor, *args, &task
end | @!macro promises.shortcut.on
@return [Future] | then | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def then_on(executor, *args, &task)
ThenPromise.new_blocked_by1(self, @DefaultExecutor, executor, args, &task).future
end | Chains the task to be executed asynchronously on executor after it fulfills. Does not run
the task if it rejects. It will resolve though, triggering any dependent futures.
@!macro promises.param.executor
@!macro promises.param.args
@!macro promise.param.task-future
@return [Future]
@yield [value, *args] to the task. | then_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def rescue(*args, &task)
rescue_on @DefaultExecutor, *args, &task
end | @!macro promises.shortcut.on
@return [Future] | rescue | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def rescue_on(executor, *args, &task)
RescuePromise.new_blocked_by1(self, @DefaultExecutor, executor, args, &task).future
end | Chains the task to be executed asynchronously on executor after it rejects. Does not run
the task if it fulfills. It will resolve though, triggering any dependent futures.
@!macro promises.param.executor
@!macro promises.param.args
@!macro promise.param.task-future
@return [Future]
@yield [reason, *args] to the task. | rescue_on | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def zip(other)
if other.is_a?(Future)
ZipFuturesPromise.new_blocked_by2(self, other, @DefaultExecutor).future
else
ZipFutureEventPromise.new_blocked_by2(self, other, @DefaultExecutor).future
end
end | @!macro promises.method.zip
@return [Future] | zip | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def any(event_or_future)
AnyResolvedFuturePromise.new_blocked_by2(self, event_or_future, @DefaultExecutor).future
end | Creates a new event which will be resolved when the first of receiver, `event_or_future`
resolves. Returning future will have value nil if event_or_future is event and resolves
first.
@return [Future] | any | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def delay
event = DelayPromise.new(@DefaultExecutor).event
ZipFutureEventPromise.new_blocked_by2(self, event, @DefaultExecutor).future
end | Creates new future dependent on receiver which will not evaluate until touched, see {#touch}.
In other words, it inserts delay into the chain of Futures making rest of it lazy evaluated.
@return [Future] | delay | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def schedule(intended_time)
chain do
event = ScheduledPromise.new(@DefaultExecutor, intended_time).event
ZipFutureEventPromise.new_blocked_by2(self, event, @DefaultExecutor).future
end.flat
end | @!macro promise.method.schedule
@return [Future] | schedule | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def flat_future(level = 1)
FlatFuturePromise.new_blocked_by1(self, level, @DefaultExecutor).future
end | Creates new future which will have result of the future returned by receiver. If receiver
rejects it will have its rejection.
@param [Integer] level how many levels of futures should flatten
@return [Future] | flat_future | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def flat_event
FlatEventPromise.new_blocked_by1(self, @DefaultExecutor).event
end | Creates new event which will be resolved when the returned event by receiver is.
Be careful if the receiver rejects it will just resolve since Event does not hold reason.
@return [Event] | flat_event | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_fulfillment(*args, &callback)
on_fulfillment_using @DefaultExecutor, *args, &callback
end | @!macro promises.shortcut.using
@return [self] | on_fulfillment | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_fulfillment!(*args, &callback)
add_callback :callback_on_fulfillment, args, callback
end | Stores the callback to be executed synchronously on resolving thread after it is
fulfilled. Does nothing on rejection.
@!macro promises.param.args
@!macro promise.param.callback
@return [self]
@yield [value, *args] to the callback. | on_fulfillment! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_fulfillment_using(executor, *args, &callback)
add_callback :async_callback_on_fulfillment, executor, args, callback
end | Stores the callback to be executed asynchronously on executor after it is
fulfilled. Does nothing on rejection.
@!macro promises.param.executor
@!macro promises.param.args
@!macro promise.param.callback
@return [self]
@yield [value, *args] to the callback. | on_fulfillment_using | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_rejection(*args, &callback)
on_rejection_using @DefaultExecutor, *args, &callback
end | @!macro promises.shortcut.using
@return [self] | on_rejection | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_rejection!(*args, &callback)
add_callback :callback_on_rejection, args, callback
end | Stores the callback to be executed synchronously on resolving thread after it is
rejected. Does nothing on fulfillment.
@!macro promises.param.args
@!macro promise.param.callback
@return [self]
@yield [reason, *args] to the callback. | on_rejection! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def on_rejection_using(executor, *args, &callback)
add_callback :async_callback_on_rejection, executor, args, callback
end | Stores the callback to be executed asynchronously on executor after it is
rejected. Does nothing on fulfillment.
@!macro promises.param.executor
@!macro promises.param.args
@!macro promise.param.callback
@return [self]
@yield [reason, *args] to the callback. | on_rejection_using | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def run(run_test = method(:run_test))
RunFuturePromise.new_blocked_by1(self, @DefaultExecutor, run_test).future
end | Allows to use futures as green threads. The receiver has to evaluate to a future which
represents what should be done next. It basically flattens indefinitely until non Future
values is returned which becomes result of the returned future. Any encountered exception
will become reason of the returned future.
@return [Future]
@param [#call(value)] run_test
an object which when called returns either Future to keep running with
or nil, then the run completes with the value.
The run_test can be used to extract the Future from deeper structure,
or to distinguish Future which is a resulting value from a future
which is suppose to continue running.
@example
body = lambda do |v|
v += 1
v < 5 ? Promises.future(v, &body) : v
end
Promises.future(0, &body).run.value! # => 5 | run | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def to_event
event = Promises.resolvable_event
ensure
chain_resolvable(event)
end | Converts future to event which is resolved when future is resolved by fulfillment or rejection.
@return [Event] | to_event | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def resolve(raise_on_reassign = true, reserved = false)
resolve_with RESOLVED, raise_on_reassign, reserved
end | @!macro raise_on_reassign
@raise [MultipleAssignmentError] when already resolved and raise_on_reassign is true.
@!macro promise.param.raise_on_reassign
@param [Boolean] raise_on_reassign should method raise exception if already resolved
@return [self, false] false is returned when raise_on_reassign is false and the receiver
is already resolved.
Makes the event resolved, which triggers all dependent futures.
@!macro promise.param.raise_on_reassign
@!macro promise.param.reserved
@param [true, false] reserved
Set to true if the resolvable is {#reserve}d by you,
marks resolution of reserved resolvable events and futures explicitly.
Advanced feature, ignore unless you use {Resolvable#reserve} from edge. | resolve | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def with_hidden_resolvable
@with_hidden_resolvable ||= EventWrapperPromise.new_blocked_by1(self, @DefaultExecutor).event
end | Creates new event wrapping receiver, effectively hiding the resolve method.
@return [Event] | with_hidden_resolvable | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def wait(timeout = nil, resolve_on_timeout = false)
super(timeout) or if resolve_on_timeout
# if it fails to resolve it was resolved in the meantime
# so return true as if there was no timeout
!resolve(false)
else
false
end
end | Behaves as {AbstractEventFuture#wait} but has one additional optional argument
resolve_on_timeout.
@param [true, false] resolve_on_timeout
If it times out and the argument is true it will also resolve the event.
@return [self, true, false]
@see AbstractEventFuture#wait | wait | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def resolve(fulfilled = true, value = nil, reason = nil, raise_on_reassign = true, reserved = false)
resolve_with(fulfilled ? Fulfilled.new(value) : Rejected.new(reason), raise_on_reassign, reserved)
end | Makes the future resolved with result of triplet `fulfilled?`, `value`, `reason`,
which triggers all dependent futures.
@param [true, false] fulfilled
@param [Object] value
@param [Object] reason
@!macro promise.param.raise_on_reassign
@!macro promise.param.reserved | resolve | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def fulfill(value, raise_on_reassign = true, reserved = false)
resolve_with Fulfilled.new(value), raise_on_reassign, reserved
end | Makes the future fulfilled with `value`,
which triggers all dependent futures.
@param [Object] value
@!macro promise.param.raise_on_reassign
@!macro promise.param.reserved | fulfill | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def reject(reason, raise_on_reassign = true, reserved = false)
resolve_with Rejected.new(reason), raise_on_reassign, reserved
end | Makes the future rejected with `reason`,
which triggers all dependent futures.
@param [Object] reason
@!macro promise.param.raise_on_reassign
@!macro promise.param.reserved | reject | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def evaluate_to(*args, &block)
promise.evaluate_to(*args, block)
end | Evaluates the block and sets its result as future's value fulfilling, if the block raises
an exception the future rejects with it.
@yield [*args] to the block.
@yieldreturn [Object] value
@return [self] | evaluate_to | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def evaluate_to!(*args, &block)
promise.evaluate_to(*args, block).wait!
end | Evaluates the block and sets its result as future's value fulfilling, if the block raises
an exception the future rejects with it.
@yield [*args] to the block.
@yieldreturn [Object] value
@return [self]
@raise [Exception] also raise reason on rejection. | evaluate_to! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def wait(timeout = nil, resolve_on_timeout = nil)
super(timeout) or if resolve_on_timeout
# if it fails to resolve it was resolved in the meantime
# so return true as if there was no timeout
!resolve(*resolve_on_timeout, false)
else
false
end
end | @!macro promises.resolvable.resolve_on_timeout
@param [::Array(true, Object, nil), ::Array(false, nil, Exception), nil] resolve_on_timeout
If it times out and the argument is not nil it will also resolve the future
to the provided resolution.
Behaves as {AbstractEventFuture#wait} but has one additional optional argument
resolve_on_timeout.
@!macro promises.resolvable.resolve_on_timeout
@return [self, true, false]
@see AbstractEventFuture#wait | wait | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def wait!(timeout = nil, resolve_on_timeout = nil)
super(timeout) or if resolve_on_timeout
if resolve(*resolve_on_timeout, false)
false
else
# if it fails to resolve it was resolved in the meantime
# so return true as if there was no timeout
raise self if rejected?
true
end
else
false
end
end | Behaves as {Future#wait!} but has one additional optional argument
resolve_on_timeout.
@!macro promises.resolvable.resolve_on_timeout
@return [self, true, false]
@raise [Exception] {#reason} on rejection
@see Future#wait! | wait! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def value(timeout = nil, timeout_value = nil, resolve_on_timeout = nil)
if wait_until_resolved timeout
internal_state.value
else
if resolve_on_timeout
unless resolve(*resolve_on_timeout, false)
# if it fails to resolve it was resolved in the meantime
# so return value as if there was no timeout
return internal_state.value
end
end
timeout_value
end
end | Behaves as {Future#value} but has one additional optional argument
resolve_on_timeout.
@!macro promises.resolvable.resolve_on_timeout
@return [Object, timeout_value, nil]
@see Future#value | value | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def value!(timeout = nil, timeout_value = nil, resolve_on_timeout = nil)
if wait_until_resolved! timeout
internal_state.value
else
if resolve_on_timeout
unless resolve(*resolve_on_timeout, false)
# if it fails to resolve it was resolved in the meantime
# so return value as if there was no timeout
raise self if rejected?
return internal_state.value
end
end
timeout_value
end
end | Behaves as {Future#value!} but has one additional optional argument
resolve_on_timeout.
@!macro promises.resolvable.resolve_on_timeout
@return [Object, timeout_value, nil]
@raise [Exception] {#reason} on rejection
@see Future#value! | value! | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def reason(timeout = nil, timeout_value = nil, resolve_on_timeout = nil)
if wait_until_resolved timeout
internal_state.reason
else
if resolve_on_timeout
unless resolve(*resolve_on_timeout, false)
# if it fails to resolve it was resolved in the meantime
# so return value as if there was no timeout
return internal_state.reason
end
end
timeout_value
end
end | Behaves as {Future#reason} but has one additional optional argument
resolve_on_timeout.
@!macro promises.resolvable.resolve_on_timeout
@return [Exception, timeout_value, nil]
@see Future#reason | reason | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def result(timeout = nil, resolve_on_timeout = nil)
if wait_until_resolved timeout
internal_state.result
else
if resolve_on_timeout
unless resolve(*resolve_on_timeout, false)
# if it fails to resolve it was resolved in the meantime
# so return value as if there was no timeout
internal_state.result
end
end
# otherwise returns nil
end
end | Behaves as {Future#result} but has one additional optional argument
resolve_on_timeout.
@!macro promises.resolvable.resolve_on_timeout
@return [::Array(Boolean, Object, Exception), nil]
@see Future#result | result | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def with_hidden_resolvable
@with_hidden_resolvable ||= FutureWrapperPromise.new_blocked_by1(self, @DefaultExecutor).future
end | Creates new future wrapping receiver, effectively hiding the resolve method and similar.
@return [Future] | with_hidden_resolvable | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb | Apache-2.0 |
def initialize(delay, opts = {}, &task)
raise ArgumentError.new('no block given') unless block_given?
raise ArgumentError.new('seconds must be greater than zero') if delay.to_f < 0.0
super(NULL, opts, &nil)
synchronize do
ns_set_state(:unscheduled)
@parent = opts.fetch(:timer_set, Concurrent.global_timer_set)
@args = get_arguments_from(opts)
@delay = delay.to_f
@task = task
@time = nil
@executor = Options.executor_from_options(opts) || Concurrent.global_io_executor
self.observers = Collection::CopyOnNotifyObserverSet.new
end
end | Schedule a task for execution at a specified future time.
@param [Float] delay the number of seconds to wait for before executing the task
@yield the task to be performed
@!macro executor_and_deref_options
@option opts [object, Array] :args zero or more arguments to be passed the task
block on execution
@raise [ArgumentError] When no block is given
@raise [ArgumentError] When given a time that is in the past | initialize | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def initial_delay
synchronize { @delay }
end | The `delay` value given at instanciation.
@return [Float] the initial delay. | initial_delay | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def schedule_time
synchronize { @time }
end | The monotonic time at which the the task is scheduled to be executed.
@return [Float] the schedule time or nil if `unscheduled` | schedule_time | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def cancelled?
synchronize { ns_check_state?(:cancelled) }
end | Has the task been cancelled?
@return [Boolean] true if the task is in the given state else false | cancelled? | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def processing?
synchronize { ns_check_state?(:processing) }
end | In the task execution in progress?
@return [Boolean] true if the task is in the given state else false | processing? | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def cancel
if compare_and_set_state(:cancelled, :pending, :unscheduled)
complete(false, nil, CancelledOperationError.new)
# To avoid deadlocks this call must occur outside of #synchronize
# Changing the state above should prevent redundant calls
@parent.send(:remove_task, self)
else
false
end
end | Cancel this task and prevent it from executing. A task can only be
cancelled if it is pending or unscheduled.
@return [Boolean] true if successfully cancelled else false | cancel | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def reset
synchronize{ ns_reschedule(@delay) }
end | Reschedule the task using the original delay and the current time.
A task can only be reset while it is `:pending`.
@return [Boolean] true if successfully rescheduled else false | reset | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def reschedule(delay)
delay = delay.to_f
raise ArgumentError.new('seconds must be greater than zero') if delay < 0.0
synchronize{ ns_reschedule(delay) }
end | Reschedule the task using the given delay and the current time.
A task can only be reset while it is `:pending`.
@param [Float] delay the number of seconds to wait for before executing the task
@return [Boolean] true if successfully rescheduled else false
@raise [ArgumentError] When given a time that is in the past | reschedule | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def execute
if compare_and_set_state(:pending, :unscheduled)
synchronize{ ns_schedule(@delay) }
end
self
end | Execute an `:unscheduled` `ScheduledTask`. Immediately sets the state to `:pending`
and starts counting down toward execution. Does nothing if the `ScheduledTask` is
in any state other than `:unscheduled`.
@return [ScheduledTask] a reference to `self` | execute | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def ns_schedule(delay)
@delay = delay
@time = Concurrent.monotonic_time + @delay
@parent.send(:post_task, self)
end | Schedule the task using the given delay and the current time.
@param [Float] delay the number of seconds to wait for before executing the task
@return [Boolean] true if successfully rescheduled else false
@!visibility private | ns_schedule | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def ns_reschedule(delay)
return false unless ns_check_state?(:pending)
@parent.send(:remove_task, self) && ns_schedule(delay)
end | Reschedule the task using the given delay and the current time.
A task can only be reset while it is `:pending`.
@param [Float] delay the number of seconds to wait for before executing the task
@return [Boolean] true if successfully rescheduled else false
@!visibility private | ns_reschedule | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/scheduled_task.rb | Apache-2.0 |
def initialize(opts = {}, &task)
raise ArgumentError.new('no block given') unless block_given?
super
set_deref_options opts
end | Create a new TimerTask with the given task and configuration.
@!macro timer_task_initialize
@param [Hash] opts the options defining task execution.
@option opts [Integer] :execution_interval number of seconds between
task executions (default: EXECUTION_INTERVAL)
@option opts [Boolean] :run_now Whether to run the task immediately
upon instantiation or to wait until the first # execution_interval
has passed (default: false)
@!macro deref_options
@raise ArgumentError when no block is given.
@yield to the block after :execution_interval seconds have passed since
the last yield
@yieldparam task a reference to the `TimerTask` instance so that the
block can control its own lifecycle. Necessary since `self` will
refer to the execution context of the block rather than the running
`TimerTask`.
@return [TimerTask] the new `TimerTask` | initialize | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | Apache-2.0 |
def execute
synchronize do
if @running.false?
@running.make_true
schedule_next_task(@run_now ? 0 : @execution_interval)
end
end
self
end | Execute a previously created `TimerTask`.
@return [TimerTask] a reference to `self`
@example Instance and execute in separate steps
task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" }
task.running? #=> false
task.execute
task.running? #=> true
@example Instance and execute in one line
task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" }.execute
task.running? #=> true | execute | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | Apache-2.0 |
def execution_interval
synchronize { @execution_interval }
end | @!attribute [rw] execution_interval
@return [Fixnum] Number of seconds after the task completes before the
task is performed again. | execution_interval | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | Apache-2.0 |
def timeout_interval
warn 'TimerTask timeouts are now ignored as these were not able to be implemented correctly'
end | @!attribute [rw] timeout_interval
@return [Fixnum] Number of seconds the task can run before it is
considered to have failed. | timeout_interval | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/timer_task.rb | Apache-2.0 |
def initialize(size)
@size = size
@tuple = tuple = ::Array.new(size)
i = 0
while i < size
tuple[i] = Concurrent::AtomicReference.new
i += 1
end
end | Create a new tuple of the given size.
@param [Integer] size the number of elements in the tuple | initialize | ruby | collabnix/kubelabs | .bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/tuple.rb | https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/tuple.rb | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.