From: Eric Wong Date: 2012-04-14T10:23:56+09:00 Subject: [ruby-core:44353] Re: [ruby-trunk - Feature #6293][Open] new queue / blocking queues "tenderlovemaking (Aaron Patterson)" wrote: > Whenever I use queues, I either use them in a blocking or non-blocking > manner only, so I have separated them in to two classes Thread::Queue, > and Thread::BlockingQueue. I don't think queues should be limited to strictly blocking/non-blocking. Outside of Ruby, but I've occassionally needed queues that could toggle between blocking/non-blocking (even in the same thread) to enforce some sort of fairness. Something like: while task = queue.take while task.run_one_timeslice if pending_task = queue.trytake # non-blocking # reschedule task if another task shows up queue.push(task) task = pending_task end end end Also, I very often use queues (often Unix pipes) where one end is blocking and the other end is not (though you don't implement non-blocking push at all)