Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crufter/jobs
A Cronlike job scheduler in Haskell.
https://github.com/crufter/jobs
Last synced: 22 days ago
JSON representation
A Cronlike job scheduler in Haskell.
- Host: GitHub
- URL: https://github.com/crufter/jobs
- Owner: crufter
- License: bsd-3-clause
- Created: 2013-03-23T19:28:38.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-03-23T19:57:01.000Z (almost 12 years ago)
- Last Synced: 2024-11-30T21:48:44.047Z (23 days ago)
- Language: Haskell
- Size: 168 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Jobs
=====With the help of Jobs, you can start, manage and stop asynchronously, periodically running tasks.
It is threadsafe and easy to use.
```haskell
{-# LANGUAGE OverloadedStrings #-}
import Jobs
```Let's acquire a new job scheduler.
```haskell
> :t new
new :: IO Scheduler
> jobs <- new
```Now this, by default is not running. Let's add two jobs to it.
```haskell
-- job name interval IO computation
> register jobs "1beep" "7s" $ putStr "\a"
> register jobs "2beep" "11s" $ putStr "\a\a"
```If you try putStr "\a" by itself you can note that instead of printing out some weird character,
it makes your computer beep. This is perfect for our use case because we can hear what's going on
in an other thread.We must start the execution of the jobs with the next command, but before that, we must change the clock speed
of the scheduler, because by default it is aimed at slower tasks.```haskell
> setInterval jobs 1
> startExec jobs
```We now heard 3 beeps, because at start the scheduler runs all tasks. From that point, the scheduler will run the task according
to the timing we specified:Example: Description
3s Every 3 seconds
5m Every 5 minutes
2h Every 2 hours
7d Every 7 days
2w Every two weeksWe can stop the execution of task by issuing
```haskell
> stopExec jobs
```More coming soon.