diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-27 14:26:26 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-27 14:26:26 -0700 |
commit | 2187b5f2f1d383b7a46baf72334c9a3332a23e84 (patch) | |
tree | 5648f4617a6e92a2a741f540de9fe5f356ebc94d /railties/lib/rails | |
parent | 673fe05899706e2e4eef28b6f749eab1b3df5d82 (diff) | |
download | rails-2187b5f2f1d383b7a46baf72334c9a3332a23e84.tar.gz rails-2187b5f2f1d383b7a46baf72334c9a3332a23e84.tar.bz2 rails-2187b5f2f1d383b7a46baf72334c9a3332a23e84.zip |
Extend stdlib queue for the test queue
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/queueing.rb | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/railties/lib/rails/queueing.rb b/railties/lib/rails/queueing.rb index 4892f85ae1..516447315f 100644 --- a/railties/lib/rails/queueing.rb +++ b/railties/lib/rails/queueing.rb @@ -7,27 +7,11 @@ module Rails # # Jobs are run in a separate thread to catch mistakes where code # assumes that the job is run in the same thread. - class TestQueue - attr_reader :contents - - def initialize - @contents = [] - end - + class TestQueue < ::Queue def drain # run the jobs in a separate thread so assumptions of synchronous # jobs are caught in test mode. - t = Thread.new do - while job = @contents.shift - job.run - end - end - t.join - end - - # implement the Queue API - def push(object) - @contents << object + Thread.new { pop.run until empty? }.join end end |