Sha256: dbefb2ee3678802ddc079db68e2add71c72edeb43c26a347d03af36903252f2b
Contents?: true
Size: 705 Bytes
Versions: 1
Compression:
Stored size: 705 Bytes
Contents
require "tennis" require "tennis/backend/memory" logger = Logger.new(STDOUT) logger.level = Logger::DEBUG Tennis.configure do |config| config.backend = Tennis::Backend::Memory.new(logger: logger) config.logger = logger end class Job include Tennis::Job def sum(*numbers) sleep 0.4 total = numbers.inject(&:+) puts "Sum #{numbers} => #{total}" end end require "tennis/launcher" # Instanciate a job and add the sum to the job to do. numbers = (1..9).to_a 10.times do Job.new.async.sum(*numbers.sample(3)) end # Start Tennis. launcher = Tennis::Launcher.new(concurrency: 2, job_classes: [Job]) launcher.async.start # Wait 1 seconds and stop Tennis sleep 1 launcher.async.stop
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tennis-jobs-0.4.0 | examples/async_sum.rb |