Method: Hx::Interop::TaskGroup#run

Defined in:
lib/interop/task_group.rb

#runObject

Run the given block in a new thread. Calls to #wait will block until it has finished running.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/interop/task_group.rb', line 12

def run
  @mutex.synchronize { @count += 1 }
  Thread.new do
    yield
  ensure
    @mutex.synchronize do
      @count -= 1
      @condition.broadcast if @count.zero?
    end
  end
end