lib/polyphony/core/global_api.rb
def move_on_after(interval, with_value: nil, &block)
      if block.arity > 0
        move_on_after_with_optional_reset(interval, with_value, &block)
      else
        Polyphony.backend_timeout(interval, nil, with_value, &block)
      end
    end
# call-seq:
#   move_on_after(interval) { ... }
#   move_on_after(interval, with_value: value) { ... }
#   move_on_after(interval) { |canceller| ... }
#   move_on_after(interval, with_value: value) { |canceller| ... }
#
# Runs the given block after setting up a cancellation timer for
# cancellation. If the cancellation timer elapses, the execution will be
# interrupted with a `Polyphony::MoveOn` exception, which will be rescued,
# and with cause the operation to return the given value.
#
# This method should be used when a timeout is to be handled locally,
# without generating an exception that is to propagated down the call stack
# or up the fiber tree.
#
# Example of normal use:
#
#   move_on_after(10) {
#     sleep 60
#     42
#   } #=> nil
#
#   move_on_after(10, with_value: :oops) {
#     sleep 60
#     42
#   } #=> :oops
#
# The timeout period can be reset by passing a block that takes a single
# argument. The block will be provided with the canceller fiber. To reset
# the timeout, use `Fiber#reset`, as shown in the following example:
#
#   move_on_after(10) do |timeout|
#     loop do
#       msg = socket.gets
#       timeout.reset
#       handle_msg(msg)
#     end
#   end
#
# @param interval [Number] timout in seconds
# @param with_value: [any] return value in case of timeout
# @param &block [Proc] block to execute
# @return [any] block's return value


Runs the given block after setting up a cancellation timer for
cancellation. If the cancellation timer elapses, the execution will be
interrupted with a `Polyphony::MoveOn` exception, which will be rescued,
and with cause the operation to return the given value.

This method should be used when a timeout is to be handled locally,
without generating an exception that is to propagated down the call stack
or up the fiber tree.

Example of normal use.





The timeout period can be reset by passing a block that takes a single
argument. The block will be provided with the canceller fiber. To reset
the timeout, use `Fiber#reset`, as shown in the following example.


Runs the given block after setting up a cancellation timer for cancellation . If the cancellation timer elapses the execution will be interrupted with a ` Polyphony :: MoveOn ` exception which will be rescued and with cause the operation to return the given value . This method should be used when a timeout is to be handled locally without generating an exception that is to propagated down the call stack or up the fiber tree . Example of normal use . The timeout period can be reset by passing a block that takes a single argument . The block will be provided with the canceller fiber . To reset the timeout use ` Fiber#reset ` as shown in the following example .
def move_on_after(interval, with_value: nil, &block)
      if block.arity > 0
        move_on_after_with_optional_reset(interval, with_value, &block)
      else
        Polyphony.backend_timeout(interval, nil, with_value, &block)
      end
    end
def move_on_after ( interval , with_value : nil , & block ) if block . arity > 0 move_on_after_with_optional_reset ( interval , with_value , & block ) else Polyphony . backend_timeout ( interval , nil , with_value , & block ) end end
call-seq:
move_on_after(interval) { ... }
move_on_after(interval, with_value: value) { ... }
move_on_after(interval) { |canceller| ... }
move_on_after(interval, with_value: value) { |canceller| ... }
call - seq : move_on_after ( interval ) { ... } move_on_after ( interval with_value : value ) { ... } move_on_after ( interval ) { |canceller| ... } move_on_after ( interval with_value : value ) { |canceller| ... }
block's return value
block ' s return value
any
interval
timout in seconds
timout in seconds
with_value
block
with_value:
return value in case of timeout
return value in case of timeout
&block
block to execute
block to execute