From ac39c00859f763933fa86d761812f37862e91b78 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Fri, 23 Mar 2018 21:50:03 +0100 Subject: base: Add '' record data type Reifying the notion of a schedule helps reasoning about the code. Passing a schedule as an argument to related procedures allows writing simpler unit tests. * src/mcron/base.scm(): New record data type. (make-schedule, schedule-user, set-schedule-user!) (schedule-system, set-schedule-system!) (schedule-current, set-schedule-current!): New procedures. (system-job-list, user-job-list, configuration-source): Replace those global variables with ... (%global-schedule): ... this global instance. * src/mcron/base.scm (use-system-job-list, use-user-job-list) (remove-user-jobs, clear-system-jobs, add-job, find-next-jobs) (display-schedule, run-job-loop): Add '#:SCHEDULE' keyword argument. * doc/mcron.texi (The base module): Update documentation. --- doc/mcron.texi | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'doc/mcron.texi') diff --git a/doc/mcron.texi b/doc/mcron.texi index 04f92bd..f408e11 100644 --- a/doc/mcron.texi +++ b/doc/mcron.texi @@ -12,6 +12,7 @@ program for running jobs at scheduled times. Copyright @copyright{} 2003, 2005, 2006, 2012, 2014 Dale Mellor +Copyright @copyright{} 2018 Mathieu Lirzin @quotation Permission is granted to copy, distribute and/or modify this @@ -1196,7 +1197,9 @@ This procedure causes all the environment modifiers that have been specified so far to be forgotten. @end deffn -@deffn{Scheme procedure} add-job time-proc action displayable configuration-time configuration-user +@deffn{Scheme procedure} add-job time-proc action displayable @ + configuration-time configuration-user @ + [#:schedule @var{%global-schedule}] This procedure adds a job specification to the list of all jobs to run. @var{time-proc} should be a procedure taking exactly one argument which will be a UNIX time. This procedure must compute the next time @@ -1211,7 +1214,8 @@ computed. Finally, @var{configuration-user} should be the passwd entry for the user under whose personality the job is to run. @end deffn -@deffn{Scheme procedure} run-job-loop . fd-list +@deffn{Scheme procedure} run-job-loop @var{fd-list} @ + [#:schedule @var{%global-schedule}] @cindex file descriptors @cindex interrupting the mcron loop This procedure returns only under exceptional circumstances, but @@ -1225,15 +1229,16 @@ before calling the @code{run-job-loop} procedure again to resume execution of the mcron base. @end deffn -@deffn{Scheme procedure} remove-user-jobs user - +@deffn{Scheme procedure} remove-user-jobs user @ + [#:schedule @var{%global-schedule}] The argument @var{user} should be a string naming a user (his login name), or an integer UID, or an object representing the user's passwd entry. All jobs on the current job list that are scheduled to be run under this personality are removed from the job list. @end deffn -@deffn{Scheme procedure} display-schedule @var{count} [@var{port}] +@deffn{Scheme procedure} display-schedule @var{count} [@var{port}] @ + [#:schedule @var{%global-schedule}] @cindex schedule of jobs This procedure is used to display a textual list of the next COUNT jobs to run. -- cgit v1.2.3