Sha256: 4a6cfd5b2faf431054837f7f789ca805ca2751e06baad41dd647edcf5800b850

Contents?: true

Size: 441 Bytes

Versions: 2

Compression:

Stored size: 441 Bytes

Contents

module Bacon
  class Context
    # Executes a given block on an async concurrent GCD queue (which is a
    # different thread) and returns the return value of the block, which is
    # expected to be either true or false.
    def on_thread(&block)
      @result = false
      group = Dispatch::Group.new
      Dispatch::Queue.concurrent.async(group) do
        @result = block.call
      end
      group.wait
      @result
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cdq-0.1.2 spec/helpers/thread_helper.rb
cdq-0.1.1 spec/helpers/thread_helper.rb