![]() | ![]() | ![]() | make-scheduled-function | ![]() |
|
| function
&key name
=> scheduled-function | [Function] |
Purpose
Create a scheduled function.
Package :portable-threads
Module :portable-threads
Arguments and values
| function | A function designator specifying a function object of one argument | |
| name | An object (typically a string or a symbol; default is
function, if function is a symbol, otherwise nil)
| |
| scheduled-function | A scheduled function |
Returns
The newly created scheduled function.
Errors
Threads (multiprocessing) is not supported on the
Common Lisp implementation.
Description
Unless the run time of function is brief, it
should spawn a new thread in which to perform its activities
so as to avoid delaying the invocation of a subsequent
scheduled function.
See also
*schedule-function-verbose*
all-scheduled-functions
schedule-function
schedule-function-relative
scheduled-function-name
scheduled-function-repeat-interval
spawn-periodic-function
unschedule-function
Examples
Create a scheduled function that simply prints "Hello" when
invoked:
> (make-scheduled-function
#'(lambda (scheduled-function)
(declare (ignore scheduled-function))
(print "Hello"))
:name 'hello)
#<scheduled-function hello [unscheduled]>
>
A more complex scheduled function that spawns a new thread to do its work and randomly sets whether to reschedule itself (and at what interval):
> (defun complex-function (scheduled-function)
(let ((interval (random 100)))
(setf (scheduled-function-repeat-interval scheduled-function)
(if (plusp interval)
;; repeat 1-99 seconds from now:
interval
;; don't repeat 1% of the time:
nil)))
(spawn-thread "Lots of stuff doer" #'do-lots-of-stuff))
complex-function
> (make-scheduled-function 'complex-function)
#<scheduled-function complex-function [unscheduled]>
>
The GBBopen Project
![]() | ![]() | ![]() | make-scheduled-function | ![]() |