Sha256: a9eaea2877db259b3626ef61e22b3e8bec66e71aef20a20db90f37a6e84827eb

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Fear
  # You're strongly discouraged to use this module since it may lead to deadlocks,
  # and reduced performance. Although, blocking may be useful in some cases (e.g. in tests)
  #
  # @see https://stackoverflow.com/questions/38155159/why-doesnt-scalas-future-have-a-get-getmaxduration-method-forcing-us-to
  module Await
    # Blocks until +Fear::Awaitable+ reached completed state and returns itself
    # or raises +TimeoutError+
    #
    # @param awaitable [Fear::Awaitable]
    # @param at_most [Fixnum] timeout in seconds
    # @return [Fear::Awaitable]
    # @raise [Timeout::Error]
    #
    module_function def ready(awaitable, at_most)
      awaitable.__ready__(at_most)
    end

    # Blocks until +Fear::Awaitable+ reached completed state and returns its value
    # or raises +TimeoutError+
    #
    # @param awaitable [Fear::Awaitable]
    # @param at_most [Fixnum] timeout in seconds
    # @return [any]
    # @raise [Timeout::Error]
    #
    module_function def result(awaitable, at_most)
      awaitable.__result__(at_most)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fear-3.0.0 lib/fear/await.rb
fear-2.0.1 lib/fear/await.rb
fear-2.0.0 lib/fear/await.rb
fear-1.2.0 lib/fear/await.rb
fear-1.1.0 lib/fear/await.rb