Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Rails::Queueing::TestQueue run order #6020

Merged
merged 2 commits into from Apr 27, 2012

Conversation

Projects
None yet
3 participants
Contributor

7even commented Apr 27, 2012

Rails::Queueing::TestQueue is working as a LIFO while it should be a FIFO (as we expect the first queued job to be run first).

Owner

tenderlove commented Apr 27, 2012

irb(main):001:0> require 'thread'
=> true
irb(main):002:0> q = Queue.new
=> #<Queue:0x007fa193062b38 @que=[], @waiting=[], @mutex=#<Mutex:0x007fa193062ac0>>
irb(main):003:0> q.push "first"
=> nil
irb(main):004:0> q.push "second"
=> nil
irb(main):005:0> q.push "third"
=> nil
irb(main):006:0> q.pop
=> "first"
irb(main):007:0> q.pop
=> "second"
irb(main):008:0> q.pop
=> "third"
irb(main):009:0>

Please keep the pop method as pop. Thanks!

Contributor

7even commented Apr 27, 2012

Yes, Queue is working as a FIFO, and that's perfect. But shouldn't TestQueue behave the same way? Currently calling Queue#drain goes pop-ing out the latest jobs from the @contents array.

Contributor

josevalim commented Apr 27, 2012

@tenderlove he's talking about the test queue which is an array.

Owner

tenderlove commented Apr 27, 2012

Doh! You're totally right. I completely read the diff wrong. :'(

@tenderlove tenderlove added a commit that referenced this pull request Apr 27, 2012

@tenderlove tenderlove Merge pull request #6020 from 7even/test_queue_order
Rails::Queueing::TestQueue run order
3ca7b13

@tenderlove tenderlove merged commit 3ca7b13 into rails:master Apr 27, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment