RubyGems Navigation menu

improved-queue 1.0

A simple elaboration on Ruby's native SizedQueue which allows using the queue object to re-awaken a blocked thread and cause it to abandon its blocking enqueue/dequeue operation. Useful for simplifying program logic, reducing the need for external flags/Muteces (yes, I said Muteces), and for cleanly resolving queues on program termination without risk of data loss or deadlock. Why use this queue? There are two reasons. For one thing, under several circumstances it is _considerably_ faster than Ruby's native SizedQueue. I admit I'm not entirely sure why, but I have tested this on multiple platforms and it seems to hold true as a generality. You can feel free to confirm or dispel that this advantage holds for your use case at your own leisure. The second reason is the aforementioned simplification of program logic. In the case that all data passing through the queues must be preserved on program termination, SizedQueue can require some elaborate trickery to ensure that even the most remote possibility of deadlock is removed. ImprovedSizedQueue solves this problem by making it possible to use the queue to pass control messages between threads, irrespective of the queue's actual content.

Gemfile:
= Copy to clipboard Copied!

install:
=

Versions:

  1. 1.0 - October 31, 2013 (8 KB)

Owners:

Authors:

  • Lincoln McCormick

SHA 256 checksum:

bd1e0d8cb7d58219b1e4ce7e4674851fd57040e6ee99d62d068ef0122cdf4ebe

Total downloads 3,567

For this version 3,567

License:

GPL v3

Required Ruby Version: None

Links: