Sha256: 3a60d714e001fa4f037a3576c36364292f3ffc3874a6bc0fa6159497f56262b4
Contents?: true
Size: 693 Bytes
Versions: 1
Compression:
Stored size: 693 Bytes
Contents
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'hyper_thread' require 'pcaprub' cap_pool = HyperThread.pool.new(max: 1) packets = Queue.new puts "starting capture" cap_pool.async do cap = PCAPRUB::Pcap.open_live(Pcap.lookupdev, 65535, true, 0) loop do next unless packet = cap.next packets << packet end end puts "starting parse pool" parse_pool = HyperThread.pool.new(max: 5) parse_pool.async(forever: true, count: parse_pool.max) do next unless packet = packets.pop puts packet.size end sleep 2 # let it run for roughly 2 seconds puts "shutting down capture and parsing pools" [ cap_pool, parse_pool ].each do |pool| pool.shutdown end exit 0
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hyper_thread-1.0.0 | examples/with_pcap.rb |