scheduler: Schedule tasks

Description Usage Arguments Details Value Functions Examples

Description

The following functions allow users to schedule functions in a virtual agenda, and initiate a loop that periodically checks whether any particular function is due.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
tableEnv()

addJob(code, runtime, loopid = "main")

delJob(jobid, jobnum, status, delete = TRUE)

jobList()

setLoop(
  loopid = "main",
  rate = 1,
  tolerance = 60,
  on.error = "continue",
  on.miss = "continue",
  on.complete = "terminate"
)

startLoop(loopid = "main")

stopLoop(loopid = "main")

Arguments

code

Code of any length. It will remain unevaluated until the job is run - save for the parts of the code wrapped in .() brackets.

runtime

a future timestamp (use in conjunction with now() for convenience)

loopid

A handle to an event loop.

jobid

one or multiple jobids, which serve as identifiers for the scheduled jobs, to be deleted

jobnum

Number of job(s) to be deleted

status

status of job(s) to be deleted

delete

Logical. If true, deletes jobs from schedule. If false, sets their status to 'disabled' instead. Default is TRUE.

rate

numeric, in seconds. How often should the loop check for a new task to be run?

tolerance

numeric, in seconds; jobs that were scheduled this many seconds in the past will still be run. Jobs beyond this point will be considered missed.

on.error

character; what is to be done when a job results in an error? Defaults to "continue".

on.miss

character; what is to be done when a job is missed? Defaults to "continue".

on.complete

character; what is to be done to the loop when there are no more jobs to be run? Defaults to "terminate".

Details

A job can be any line(s) of code, and it will be run at the designated timstamp if the associated loop is running.

startLoop() starts a loop.

stopLoop() stops a loop.

Value

delJob() returns TRUE if successful, FALSE if failed.

Functions

Examples

1
2
3
4
5
6
7
addJob(code=print("Hello World"),runtime=now()+5)
delme<-addJob(code=print("Goodbye World"),runtime=now()+6)
delJob(jobid=delme)
addJob(code=stopLoop(),runtime=now()+7)
setLoop(rate=0.5)
print(jobList())
startLoop()

Spiritspeak/often documentation built on Feb. 2, 2021, 11:41 a.m.