Ruby Unified Queues
unified-queues is an unified queue interface which unifies several both normal and priority queue implementations to the single queue API. Usage is simple:
require "unified-queues" # Depq require "depq" depq_queue = UnifiedQueues::Single::new(Depq) # Ruby Array array_queue = UnifiedQueues::Single::new(Array) # ...the same API! depq_queue.push(:foo) depq_queue.pop! # will return :foo array_queue.push(:foo) array_queue.pop! # will return :foo
Evented queues are also supported by transparent way; simply provide blocks to calls instead of expecting return values. Currently, the following classes are supported:
And for multiqueues:
Multiqueue is a queue which is composed of more queues and single queue can be selected for writing into or reading from. An example of this type of queues are for example some queue servers which typically contain more than one queue. By this way, an unified queue interface can be implemented for more queue servers too.
Reasonable example isn't available, but see the QRPC project where unified multiqueues are implemented.
Multiqueue driver for single unified queue interface is also implemented, so it's possible to build a multiqueue interface from the common datatypes or Ruby priority queues implementations by an universal and transparent way.
Hardcore example can by for example following (bonus points for decoding what it does):
UnifiedQueues::Multi::new UnifiedQueues::Single, ::EM::Wrapper::new(REUQ), UnifiedQueues::Single, CPriorityQueue
Well, it creates an unified queue interface from the
library, wraps it to an evented interface (converts standard
interface to the evented one), converts it to the evented unified
queue interface again and creates a multiqueue interface from it. It
may sounds difficulty, but it simply creates an evented unified
multiqueue interface from non-evented proprietary library. Cool.
- Fork it.
- Create a branch (
git checkout -b 20101220-my-change).
- Commit your changes (
git commit -am "Added something").
- Push to the branch (
git push origin 20101220-my-change).
- Create an Issue with a link to your branch.
- Enjoy a refreshing Diet Coke and wait.
Copyright © 2011 - 2012 Martin Kozák. See