Module: Kernel

Defined in:
lib/goroutine/ext.rb

Instance Method Summary collapse

Instance Method Details

#go(*args, &block) ⇒ Object



10
11
12
13
# File 'lib/goroutine/ext.rb', line 10

def go(*args, &block)
  Thread.abort_on_exception = true
  Thread.new(*args, &block)
end

#select(channels, &block) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/goroutine/ext.rb', line 2

def select(channels, &block)
  channels = Array(channels)
  loop do
    rs, _ = IO.select(channels)
    rs.each { |ch| block[ch.pop, channels.index(ch)] }
  end
end