[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Peridic tasks in MCL 2.0.1

In article <poeck-1201951033170001@wi6a65.informatik.uni-wuerzburg.de>,
 I wrote:

> For some applications we need to execute a task peridically in background.
> e.g. listening for an incomming tcp-connection.
> bla, ...

You kind soul pointed out that  periodic is spelled periodic and not
peridic. The corrected code follows.


;;;;poor mans periodic tasks in MCL without kernel hacking or undocumented
;;;;main idea ccl:*eventhook* may contain a lists of functions that are a
hook into the event system
;;;;the functions have the first chance of processing any events 

(in-package :cl-user)

(defvar *id-tasks-plist* nil)

(defun install-simple-periodic-task (id funktion interval &key
(ignore-errors t))
  (declare (ignore interval))
  ;will handle interval in the future
  (let ((old-function (getf *id-tasks-plist* id))
        (new-function #'(lambda()
                          (when (zerop (mod (get-internal-run-time) 60))
                            (if ignore-errors
                              (ignore-errors (funcall funktion))
                              (funcall funktion)
 ;otherwise normal-event-processing won't get the event
    (when old-function
      (setq ccl:*eventhook* (delete old-function ccl:*eventhook*)))
    (pushnew new-function ccl:*eventhook*)
    (setf (getf *id-tasks-plist* id)

(defun deinstall-simple-periodic-task (id)
  (setq ccl:*eventhook* (delete (getf *id-tasks-plist* id) ccl:*eventhook*)))

       (sekunde minute stunde tag monat jahr wochentag egal1 egal2)
       (declare (ignore stunde tag monat jahr wochentag egal1 egal2))
       (format ccl:*top-listener* "~2d:~2d" minute sekunde))
     (let ((a 'a))
       (+ 1 a))

(deinstall-simple-periodic-task :test)


 Karsten A. Poeck, Lehrstuhl fuer Informatik VI, Universitaet Wuerzburg
 Allesgrundweg 12, 97218 Gerbrunn, Germany
 E-mail: poeck@informatik.uni-wuerzburg.de
 Tel ++ 49  931 70561 18, Fax ++ 49 931 70561 20