Quartz Build Status

Dead simple timers in Crystal

Installation

Add this to your application's shard.yml:

dependencies:
  quartz:
    github: andrewhamon/quartz
    version: ~> 0.1.1

Usage

require "quartz"

# Execute a block after 3 seconds
Quartz::Timer.new(3) do
  puts "3 seconds"
end

# Execute block every second
Quartz::PeriodicTimer.new(1) do
  puts "tick"
end

# Make sure you yield in some way so that the timers get scheduled
sleep(5)

WARNING: Make sure you understand Crystal's concurrency model

Crystal is concurrent, but not (yet) parallel. Crystal fibers don't run immediately after being spawned, the main fiber must yield control, either explicitly by sleeping or implicitly by doing blocking IO.

See the Crystal docs for a more detailed explanation.

This has a number of consequences for timers such as this library:

Contributing

  1. Fork it ( https://github.com/andrewhamon/quartz/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request to the develop branch

Contributors