Code Monkey home page Code Monkey logo

em-throttled_queue's Introduction

Throttled Queue is a throttled queue

ThrottledQueue is just like an EM::Queue, but will pop items off itself at a pace specified by you.

NOTE: Version v1.0.0 and v1.0.1 has an unintentional flaw, and should not be used.

NOTE: I personally won’t be doing any development on this library, but I will accept pull requests. If you want take over maintenance of this library for further development, please do contact me.

Contributors

Usage

require 'em/throttled_queue'

# Example code that will pop off 2 items in total within a period of
# one second. The other items are not popped because of throttle.
EM::run do
  # Create a queue that will pop off maximum of 2 items per second.
  queue = EM::ThrottledQueue.new(2)

  queue.push 1 # you can push one item at a time
  queue.push 2, 3, 4, 5, 6 # or several at once

  5.times { queue.pop(&EM::Callback(Object, :puts)) }

  EM::add_timer(1) { EM::stop }
end

# Output:
# 1
# 2

Installation

gem install em-throttled_queue

How do I contribute?

Fork, write tests, add your code and send a pull request. If you modify existing files, please adhere to the coding standard surrounding your code. If you wish to report an issue, please use the GitHub issue tracker. I can also be contacted by mail (visible on my GitHub user page).

Development dependencies are specified in the gem specification, and can be installed using rubygems.

gem install em-throttled_queue --development

There’s also a Gemfile in the repository, allowing you to install dependencies via bundler.

bundle install

Why don’t you support 1.8.7?

There currently is no reason for me to do so. If you believe there is, file an issue.

em-throttled_queue's People

Contributors

burgestrand avatar rud avatar iblue avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.