Skip to content

Instantly share code, notes, and snippets.

@diasjorge
Created January 22, 2009 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diasjorge/50588 to your computer and use it in GitHub Desktop.
Save diasjorge/50588 to your computer and use it in GitHub Desktop.
# This is what I try in console
1.upto(1500) do |i|
MiddleMan.worker(:performance_worker).
async_test_performance(:job_key => "performance_#{i}",
:arg => "TEXTO A MOSTRAR #{i}")
end
#Worker
class PerformanceWorker < BackgrounDRb::MetaWorker
set_worker_name :performance_worker
pool_size 100
def create(args = nil)
# this method is called, when worker is loaded for the first time
end
def test_performance(arg)
logger.info("DEFER")
thread_pool.defer(:test_performance_delegated,arg)
logger.info("DEFERED")
end
private
def test_performance_delegated(arg)
logger.info "STARTED JOB #{arg}"
sleep(5)
logger.info "FINISHED JOB #{arg}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment