MacroPackage: cgToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version


Arguments: (&key process-name exit-test) &body body

Creates a new Common Graphics process that executes body and then calls event-loop. The window argument that is passed to event-loop will be the first value that was returned by the body if it is an open window, and otherwise will be nil. exit-test will be passed straight through to the call to event-loop. process-name will be the name of the process if one is passed, and otherwise a gensym'ed string beginning with "CG Process" will be used. in-cg-process returns the process that was created, which will later exit when its call to event-loop exits in its usual way.

This macro also passes *default-cg-bindings* as the initial-bindings argument to process-run-function, as described in About using multiple windowing threads in a Common Graphics application in cgide.htm.

This macro is particularly convenient when testing Common Graphics code in a Lisp that does not include the IDE, because creating windows and then calling event-loop directly in a console or emacs listener would tie up the listener until the call to event-loop exits. This is not an issue in the IDE where the IDE listeners manage their own Common Graphics event loops.

in-cg-process works only when Common Graphics has been initialized by calling initialize-cg (which is done automatically by the IDE and by any standalone application that was created from an IDE project using standard IDE tools but might not be done in other applications).

As a trivial example, the following will create a window in a new process that exits when the window is closed, due to the returned window being passed to event-loop internally:

(in-cg-process (:process-name "Simple Test")
  (make-window :foo
    :class 'frame-window
    :exterior (make-box-relative 200 200 300 200)
    :title (format nil "In process ~a"
             (mp:process-name sys:*current-process*))))

Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version