Shard Detail

quartz v0.1.1

⌚️ Crystal clear timers

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development

  github: andrewhamon/quartz


Quartz Build Status

Dead simple timers in Crystal


Add this to your application's shard.yml:

    github: andrewhamon/quartz
    version: ~> 0.1.1


require "quartz"

# Execute a block after 3 seconds do
  puts "3 seconds"

# Execute block every second do
  puts "tick"

# Make sure you yield in some way so that the timers get scheduled

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:

  • The countdown for a timer doesn't start when the timer is instantiated, only when the fiber it spawns runs. This could be an arbitrarily long time after the timer is instantiated.
  • The block you pass your timer might never get called, if the main fiber terminates too early or if it never yields control.
  • Different timers might fire in a different order than expected. A shorter timer could fire after a longer timer
  • Timers are not precise.
  • A shorter timer is not guaranteed to execute before a separate, longer timer.


  1. Fork it ( )
  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