ronin-rb / ronin-scanners

A Ruby library for Ronin that provides a Ruby interface to various third-party security scanners.
http://ronin-ruby.github.com/
GNU General Public License v2.0
27 stars 6 forks source link

Add multi-threading support to Scanner #13

Open postmodern opened 12 years ago

postmodern commented 12 years ago

Add multi-threading to Scanner. This can be done by using the ensure keyword in Scanner#each to stop all scanner threads.

Pseudo-code

class Scanner

  include Enumerable

  def each
    loop do
      yield rand(256)
      sleep 1
    end

  ensure
    puts 'stopping threads'
  end

end

scanner = Scanner.new
scanner.first(10)
# stopping threads
# => [30, 165, 245, 11, 43, 159, 13, 113, 128, 197]