Created
January 22, 2009 16:08
-
-
Save diasjorge/50588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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