Runs a Background Loop Forever

DevOps By Rultor.com We recommend RubyMine

rake PDD status Gem Version Test Coverage Yard Docs Hits-of-Code License

This simple Ruby gem helps you run a loop forever, in a background thread.

require 'always'
# Prepare, with five threads:
a = Always.new(5)
# Start them all together spinning forever with 30-seconds delay between cycles:
a.start do
  puts "I'm alive"
end
# Stop them all together:
a.stop

You may be interested to get the backtraces of the exceptions that happened most recently:

# Keep the last 10 error backtraces in memory:
a = Always.new(5, max_backtraces: 10)
# Retrieve them:
p a.backtraces

That's it.

How to contribute

Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 3.0+ and Bundler installed. Then:

bundle update
bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.