live coding and subsecond sleep

Madhu enometh at meer.net
Fri Nov 20 12:44:32 CET 2009


* fred <20091120034450.87E53DE1044 at bass.localhost> :
Wrote on Thu, 19 Nov 2009 19:44:50 -0800 (PST):

| 1. Is there a way to get subsecond waits in cmucl? SLEEP, as
| expected, doesn't do less than 1 sec

Passing a < 1.0 real value to SLEEP should be enough to sleep for below
1 sec.

| 2. The user input loop for my graphics system uses XLIB:EVENT-CASE --
| which has the odd consequence that when I call STREAKX via
| START-STREAKXING, every time I move the mouse, it terminates the
| current sleep cycle. That is, with the mouse motionless, the visual
| object is repainted every 1 second. But if I quickly circle the mouse,
| then the vizobj is repainted very much more frequently, as if being
| advanced by each mouse event. This effect is not always bad during
| performances, but I'd like to understand it and be able to control it.
| ;;actual wait interval is always 1 second ...

I see you want it to SLEEP for 0.001 seconds, but instead it SLEEPs for
1 second.

This suggests that something[*] is getting blocked somewhere where it
should not be blocked, and LISP::*PERIODIC-POLLING-FUNCTION* unblocks it
every second.

>From code/serve-event.lisp:

;;; When a *periodic-polling-function* is defined the server will not
;;; block for more than the maximum event timeout and will call the
;;; polling function if it does times out. One important use of this
;;; is to periodically call process-yield.

(defvar *periodic-polling-function*
  #-mp nil #+mp #'mp:process-yield)
(defvar *max-event-to-sec* 1)
(defvar *max-event-to-usec* 0)

Now I *suspect* this blockage will not happen if, after starting CMUCL,
you call (MP::STARTUP-IDLE-AND-TOP-LEVEL-LOOPS) before running your app,
but maybe you are already doing that?  

--
Madhu




More information about the cmucl-help mailing list