Sha256: 6de41e7e01aee193589ad1d3647fa7363792294c9a540f7b6b0a444e1d26933b
Contents?: true
Size: 733 Bytes
Versions: 28
Compression:
Stored size: 733 Bytes
Contents
module Steep class ThreadWaiter attr_reader :objects, :queue, :waiter_threads def initialize(objects) @objects = objects @queue = Thread::Queue.new() @waiter_threads = Set[].compare_by_identity objects.each do |object| thread = yield(object) waiter_thread = Thread.new(thread) do |thread| Thread.current.report_on_exception = false begin thread.join ensure queue << [object, thread] end end waiter_threads << waiter_thread end end def wait_one unless waiter_threads.empty? obj, th = queue.pop() waiter_threads.delete(th) obj end end end end
Version data entries
28 entries across 28 versions & 1 rubygems