![]() | ![]() | ![]() | make-scheduled-function | ![]() |
| function
&key name name-test marker marker-test context | [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 nil )
| |
name-test | A function designator specifying a
function object of two arguments that returns a
generalized boolean (default is #'eql | |
marker | An object (default is nil )
| |
marker-test | A function designator specifying a
function object of two arguments that returns a
generalized boolean (default is #'eql | |
context | An object (default is 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 to perform the scheduled 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.
The optional marker and associated comparison marker-test can
be specified to distinguish scheduled functions with the same
name in calls to
The optional context object can be specified to store an invocation
context in the
See also
*schedule-function-verbose*
all-scheduled-functions
pause-scheduled-function-scheduler
restart-scheduled-function-scheduler
resume-scheduled-function-scheduler
schedule-function
schedule-function-relative
scheduled-function-context
scheduled-function-invocation-time
scheduled-function-marker
scheduled-function-marker-test
scheduled-function-name
scheduled-function-name-test
scheduled-function-repeat-interval
scheduled-function-scheduler-paused-p
scheduled-function-scheduler-running-p
spawn-periodic-function
unschedule-function
Examples
Create a scheduled function that simply prints "Hello"
> (make-scheduled-function #'(lambda (scheduled-function) (declare (ignore scheduled-function)) (print "Hello")) :name 'hello) #<scheduled-function hello [unscheduled]> >Create a scheduled function that individualizes the
"Hello"
> (make-scheduled-function #'(lambda (scheduled-function) (format t "~&Hello ~a~%" (scheduled-function-context scheduled-function))) :name 'hello :context "Bob") #<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 | ![]() |