0.0
No commit activity in last 3 years
No release in over 3 years
Makes working with EventMachine's queue more convenient. It adds start/stop/status methods, and keeps the queue and queue logic packed together.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.9.0

Runtime

 Project Readme

EM::WorkQueue

WorkQueue makes EventMachine's queue simpler to work with. Often when using an EventMachine queue, you will want to work on the queue. Often this is done by creating a Proc object and passing it as an argument to the queue when you call pop. WorkQueue makes this simpler by packing the queue and processing proc together. It also makes controlling the queue processing simpler with methods like start/stop/status.

Installation

Add this line to your application's Gemfile:

gem 'em-work_queue'

And then execute:

$ bundle

Or install it yourself as:

$ gem install em-work_queue

Usage

require 'rubygems'
require 'em-work_queue'
include EM::WorkQueue

EM.run do
  # Create WorkQueue instance
  wq = WorkQueue.new do |i|
    # do work...
    puts i
  end
  
  # starts processing queue
  wq.start
  
  # push work onto queue
  wq.push 'a'
  wq.push 'b'
  wq.push 'c'
  
  # stop processing queue
  wq.stop
  
  # will not be processed until start is called again
  wq.push 'd'
  
  # true or false
  wq.running?
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request