Sha256: 633736f1412211423839e1344c29174214c35bda26ec7a4b761b793a09f07944

Contents?: true

Size: 439 Bytes

Versions: 1

Compression:

Stored size: 439 Bytes

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'hyper_thread'

# spawn thread pool
pool = HyperThread.pool.new(max: 7)

# ask to spawn more threads than max value
pool.async(count: 9) do
  "this is some work"
end

# the extra jobs are in a queue
pool.queue.size 
# => 2

# spool off any queue'd jobs outside of pool
pool.todo(count: pool.queue.size) do |block|
  puts block.call 
end

# shutdown pool
pool.shutdown



Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hyper_thread-1.0.0 examples/pool_example.rb