automation-server-top-loop

Function

Summary

Package

com

Signature

automation-server-top-loop &key
exit-delay
exit-function

Arguments

exit-function

A function designator.

exit-delay

A non-negative real number specifying a time in seconds.

Description

The function
automation-server-top-loop
calls co-initialize and start-factories, and then processes messages, until the server can exit. Since COM works by messages, it will end up processing all COM requests.

exit-function
determines when the server can exit. It defaults to server-can-exit-p, which is normally the right function. This returns
t
when the COM server is not used and there are no other "working processes". See the documentation for server-can-exit-p. When
exit-function
is supplied, it needs to be a function of no arguments which returns true when the server can exit. The
exit-function
is used like a wait function: it is called repeatedly, it needs to be reasonably fast, and should not wait for anything.

After the delay
automation-server-top-loop
checks again by calling
exit-function
. If this returns false it goes on to process messages. Otherwise it stops the factories, calls co-uninitialize and returns.

Notes

automation-server-top-loop
interacts with the
deliver
keyword
:quit-when-no-windows
, such that the delivered application does not
quit
even after all CAPI windows are closed as long as
automation-server-top-loop
has not returned.

automation-server-top-loop
does not return while the server is active. Typically it will be running on its own process.

automation-server-top-loop
uses
mp:general-handle-event
to process Lisp events, so it is possible to run in the same thread operations that rely on such messages. In particular, CAPI windows can start on the same process. However, all COM input is processed in this thread, so it is probably better to start CAPI windows on other processes, so that they do not interfere with each other.