All Manuals > COM/Automation User Guide and Reference Manual > 2 COM Reference Entries

automation-server-top-loop Function

Summary

A function to run a COM server.

Package

com

Signature

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

Arguments
exit-delay
A non-negative real number specifying a time in seconds.
exit-function
A function designator.
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. exit-function is used like a wait function: it is called repeatedly, it needs to be reasonably fast, and should not wait for anything.

Once the server can exit, automation-server-top-loop delays exiting for another period of time, exit-delay seconds. exit-delay defaults to 5, and can be set by calling set-automation-server-exit-delay. If supplied, exit-delay is passed to set-automation-server-exit-delay on entry. However, later calls to set-automation-server-exit-delay can change the exit delay.

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
  1. 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.
  2. automation-server-top-loop does not return while the server is active. Typically it will be running on its own process.
  3. 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.
  4. automation-server-top-loop does not return a useful value.
See also

start-factories
stop-factories
automation-server-main
server-can-exit-p
set-automation-server-exit-delay


COM/Automation User Guide and Reference Manual - 01 Dec 2021 19:38:38