aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/queueing.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/queueing.rb')
-rw-r--r--railties/lib/rails/queueing.rb20
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