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

Re: TIME, MCL and LOOPS (fwd)

>Forwarded message:
>>From bdrobert@MEDIA-LAB.MEDIA.MIT.EDU Thu Aug 27 11:25:09 1992
>Message-Id: <9208271526.AA03549@media-lab.mit.edu>
>To: info-mcl-request@cambridge.apple.com
>Subject: TIME, MCL and LOOPS
>Date: Thu, 27 Aug 92 11:26:14 -0400
>X-Mts: smtp

First I must slap your hand. Please send questions to info-mcl, not
info-mcl-request. info-mcl-request is for requests to be added or
removed from the info-mcl mailing list.

>Any suggestions on an easy way to have a function in your LISP program
>called, every X number of ticks or seconds, without doing a loop.
>I would like the program to be operating in other functions, and every
>so often, it would jump into a function, do stuff, and return to whatever
>task it was doing before.

The documented way of doing this is with *eventhook*. The undocumented
way is with ccl::%install-periodic-task. The former is documented in the
MCL 2.0 reference. The latter is used by the example file "thermometer.lisp":

ccl::%install-periodic-task name function interval &optional flags private-data
  Install or overwrite a periodic task with the given NAME (compared
  with EQ). Will cause FUNCTION to be funcalled with no arguments once
  every INTERVAL ticks (1/60 second). Flags defaults to 0 meaning call
  your function no matter what the context. If your function does drawing
  or should not be called while event processing is being done, you
  should use one or both (logior'd together) of the following values
  for FLAGS (both are defined in "ccl:library;lispequ.lisp" so you'll
  need to (require "LISPEQU") to use them):

  $ptask_draw-flag            Your periodic task does drawing
  $ptask_event-dispatch-flag  Your periodic task should not be called
                              during EVENT-DISPATCH.

  private-data is stored in the mac heap part of theperiodic task record,
  but this will not be useful unless you are writing an interrupt routine
  (in LAP or with the foreign function interface) that needs to interact
  with a periodic task (I'll give details to anyone who thinks they
  need to do this).

ccl::%remove-periodic-task name
  Remove the periodic task with the given name.