module Marmot
Overview
Marmot is a scheduler, use it to schedule tasks.
Extended Modules
Defined in:
marmot.crConstant Summary
-
VERSION =
"0.2.0"
Instance Method Summary
-
#cancel_all_tasks : Nil
Cancels all the tasks.
-
#cron(hour, minute, second = 0, &block : Callback) : Task
Runs a task every day at hour and minute.
-
#on(channel, &block : Callback) : Task
Runs a task when a value is received on a channel.
-
#repeat(span : Time::Span, first_run = false, &block : Callback) : Task
Runs a task every given span.
-
#run : Nil
Starts scheduling the tasks.
-
#stop
Stops scheduling the tasks.
Instance Method Detail
Runs a task every day at hour and minute.
Runs a task when a value is received on a channel.
To access the value, you need to restrict the type of the task, and use
OnChannelTask#value
.
channel = Channel(Int32).new
Marmot.on(channel) { |task| puts task.as(OnChannelTask).value }
Runs a task every given span.
If first run is true, it will run as soon as the scheduler runs. Else it will wait span time, then run a first time.