-
Notifications
You must be signed in to change notification settings - Fork 12
/
tst-capi-exec.lisp
85 lines (74 loc) · 2.96 KB
/
tst-capi-exec.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;; tst-capi=exec.lisp -- Probe the intelligence of the CAPI system
;;
;; DM/RAL 02/24
;; --------------------------------------------------------------
(in-package :plotter)
;; ------------------------------------------------------------
(defun tst (pane)
(let* ((pane (plotter-pane-of pane))
(flag :not-yet)
(action (lambda (pane x y w h)
(declare (ignore x y w h))
;; This code gets executed in the redraw callback.
(capi:apply-in-pane-process pane
(lambda ()
(setf flag :done)))
(ac:send ac:println flag))))
(augment-display-list pane action t)))
#|
;; The fact that this produces a display of DONE in the Output
;; Browser, shows that CAPI is intelligent enough to recognize that
;; when executing in the CAPI thread already, there is no need to
;; send a message to your process mailbox for APPLY-IN-PANE-PROCESS.
;;
;; Had it simply sent the message to itself, we would have seen
;; NOT-YET displayed, instead of DONE.
(tst 'plt)
|#
;; ------------------------------------------------------
(defun tstx (pane)
(let* ((pane (plotter-pane-of pane))
(flag :not-yet)
(action (lambda (pane x y w h)
(declare (ignore x y w h))
;; This code gets executed in the redraw callback.
(capi:apply-in-pane-process-wait-multiple pane nil
(lambda ()
(setf flag :done)))
(ac:send ac:println flag))))
(augment-display-list pane action t)))
#|
;; The fact that this produces DONE in the Output Browser, shows that
;; the CAPI thread just directly executes the function. Had it staged
;; for later execution and then waited on its own mailbox, the system
;; should have hung.
(tstx 'plt)
|#
;; ------------------------------------------------------------
(defun tstu (pane)
(let* ((pane (plotter-pane-of pane))
(flag :not-yet))
(capi:apply-in-pane-process pane
(lambda ()
(setf flag :done)))
flag))
|#
;; The fact that this produce :NOT-YET shows that
;; APPLY-IN-PANE-PROCESS merely schedules an action at some future
;; time, but does not synchronously execute the function.
(tstu 'plt)
|#
;; ------------------------------------------------------------
(defun tstw (pane)
(let* ((pane (plotter-pane-of pane))
(flag :not-yet))
(capi:apply-in-pane-process-wait-multiple pane nil
(lambda ()
(setf flag :done)))
flag))
|#
;; The fact that this produce :DONE shows that
;; APPLY-IN-PANE-PROCESS-WAIT-MULTIPLE synchronously executes the
;; function in sequence.
(tstw 'plt)
|#