No results
2
Event Objects
dxtr edited this page 2026-10-11 18:09:35 +02:00
Table of Contents
Event Objects
An event object is a flag in the kernel: one thread sets it, others wait for it. It is how a thread with a message loop can wake a thread that waits for its results, without a Lisp condition variable.
(win32:with-event (event)
(start-work-that-calls-set-event-when-done event)
(if (win32:wait-for-event event 5)
:done
:timed-out))
make-eventmakes one. By default it is auto-reset: waking one waiting thread unsignals it again. With:manual-reset tit stays signalled untilreset-event.:signalled tmakes it signalled from the start.set-eventsignals it, and allocates nothing.reset-eventunsignals it.wait-for-eventwaits at most a timeout, in seconds, any non-negative real, or forever fornil, the default. It returns true if the event was signalled, false if the time ran out. A timeout of 0 only looks.close-eventreleases it;with-eventmakes one and releases it on leaving.
An event may be used from any thread. The wait happens in Windows, as a foreign call; on SBCL for Windows, a thread in a foreign call does not hold up the garbage collector.