QueueDing alternative to Queue

Join the chat at https://gitter.im/flajann2/queue_ding Build Status

Gem Version

Gem Version

This roughly mirrors the functionaly of Queue in allowing you to queue messages to one or more threads, and will block if the queue is empty, waking up when there is another message available.

Because this is derived directly from the Array class, it has all the expected Array functionality, with the appropriate wrappers for thread safety.

New Funtionality


Automatic tee support added, so that multiple listening threads will get the same data. There is currenly no way to turn this feature off. If this is a problem for you, let me know and I'll add a switch sooner.

You may not want this behavior if you are using queue_ding to distrubute work among listening threads, but you will want this if you need to ensure multile listeners receive the smae data, as in the case with with my dyamic interfaces for browser-based Dashboards.

Known Issues


With the new Automatic Tee Feature, there is currently no cleanup for dead threads. This could potentially lead to a memory leak situation for long running tasks. This problem will be addressed in the next release.



This is taken from the rspec tests.

require 'queue_ding'
include QueueDing

queue = QDing.new

tout = Thread.new do
  (0..1000).each{ |j|
    (i, num) = @queue.next
    expect(j).to eq i
    expect(num).to eq j * 7 + 3

tin = Thread.new do
  (0..1000).map{|i| [i, i * 7 + 3]}.each{|pair| @queue << pair }



v0.1.0 2014-08-03

Added tee capability so that you can tee queue to multiple threads
automatically. There are no settings for this. It just works. For some,
this behavior may be undesirable, so an option will be added at a later

Copyright © 2014 Fred Mitchell. See LICENSE.txt for further details.

Contributing to queue_ding

I am very open to any ideas you may have for new features you may want to see, any pull requests, etc.

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Why I Created QueueDing

I ran into an issue with Queue segfaulting on Ruby 2.1.1 and 2.1.2. I need this for my RubyNEAT project and simply has to work. Like deep_dive, this is driven by the RubyNEAT effort, which will be quite stringent. So expect to see further improvements and enhancements as the needs arise.

Funny Trivia

“Queue Ding” is actually German for “Queue Thing”, so it is my hopes my German compatriots will forgive me for any possible faux pas this might entail.

Copyright © 2014 Fred Mitchell. See LICENSE.txt for further details.