This is an old revision of the document!
WAIT
This special function pauses current LabLisp process, while other processes can perform their tasks. Expects one argument that will be evaluated repeatedly until it returns NIL
. Returns NIL
when finished waiting.
(wait T) ; is infinite loop (don't do this) (wait nil) ; no waiting
Typical use of WAIT
in LabLisp is waiting for some device controller to finish a task:
(move motor-x) ; starts moving with motor x (wait (moves? motor-x)) ; checks repeatedly if the motor x moves
The process currently in the waiting loop will be reported in the process list as “waiting”, normally running processes are reported as “running”. Since normal processing is usually quite fast, the user mostly sees the “waiting” processes only.
The mechanism behind waiting and LabLisp multitasking is following: When multiple LabLisp eval processes are running in the environment, the process control evals one expression at the time in each process, before moving to the next process. The LabLisp environment runs in separate thread from the main Qt application, but all the LabLisp eval processes run in the same thread, so the LabLisp multitasking is an emulation. When all processes are in the waiting loop, the environment slows down and the Qt/C++ thread sleeps in total 100 ms on each cycle. The 100 ms is splitted between the evaluations of the waiting conditions, so - for example - if we have four waiting processes, the process control evaluates the waiting condition…
See also: SLEEP