Skip to content

An easy-to-use task scheduler that can run arbitrary blocks

License

Notifications You must be signed in to change notification settings

pharo-contributions/Scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scheduler

An easy-to-use task scheduler for Pharo that can run arbitrary blocks

Unit Tests Coverage Status

Pharo 7 Pharo 8 Pharo 9 Pharo 10 Pharo 11

Quick start

Metacello new 
    repository: 'github://pharo-contributions/Scheduler/src';
    baseline: 'Scheduler';
    load

Pharo Scheduler

Overview

An easy-to-use task scheduler that can run arbitrary blocks:

Every so often (e.g. every hour starting now)

  • Daily at a given time
  • Periodically starting at a given time (e.g. every other hour starting a noon)
  • Per a provide schedule (e.g. using Schedule instance you can run tasks every Monday and Friday)
  • A one time task at some point in the future

For ease of use tasks can be blocks passed to the scheduler (or any object that understands #value).

Example 1

"Start a new task scheduler and keep it around"
scheduler := TaskScheduler new.

scheduler start.

Example 2

"Let's save the image every hour"
scheduler
    do: [Smalltalk snapshot: true andQuit: false]
    every: 60 minutes.

Example 3

"Let's run a backup at 2am every day"
scheduler
    do: ["backup code here"]
    at: '2am'

Example 4

"Let's perform a bank transfer every other hour starting at 1pm"
scheduler
    do: ["swiss bank account transfer code"]
    at: '1pm'
    every: 2 hours.

Example 5

"Let's do a one time email reminder"
scheduler
    doOnce: ["email reminder to go on honeymoon"]
    at: '2005-1-15T8:00'

Example 6

"Let's do a one time email reminder"
"You can delete tasks by sending #delete to them"
(scheduler taskAt: 1) delete

Example 7

"Stop the scheduler from running -- but don't delete its tasks"
scheduler stop.

Read the provided tests for more examples.

About

An easy-to-use task scheduler that can run arbitrary blocks

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •