19282
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
19273
|
3 |
"
|
|
4 |
COPYRIGHT (c) 1997 by Claus Gittinger
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
|
14 |
"{ Package: 'stx:libtool' }"
|
|
15 |
|
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
|
18 |
SystemStatusMonitor subclass:#TimerQueueMonitor
|
|
19 |
instanceVariableNames:'timeouts showTime'
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'Monitors-ST/X'
|
|
23 |
!
|
|
24 |
|
|
25 |
!TimerQueueMonitor class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 1997 by Claus Gittinger
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
|
|
40 |
|
|
41 |
!
|
|
42 |
|
|
43 |
documentation
|
|
44 |
"
|
|
45 |
This view shows smalltalk's external stream instances - a debugging tool.
|
|
46 |
|
|
47 |
[disclaimer:]
|
|
48 |
this is based on one of the oldest tools in the system, written in the early 90's.
|
|
49 |
It does in no way reflect the way GUIs are designed/written these days.
|
|
50 |
However, after all those years, they are still very very useful (and not found in many other systems)
|
|
51 |
|
|
52 |
[see also:]
|
|
53 |
Stream ExternalStream
|
|
54 |
WindowGroup
|
|
55 |
ProcessMonitor
|
|
56 |
SemaphoreMonitor OSProcessMonitor
|
|
57 |
|
|
58 |
[author:]
|
|
59 |
Claus Gittinger
|
|
60 |
|
|
61 |
[start with:]
|
19355
|
62 |
TimerQueueMonitor open
|
19273
|
63 |
"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!TimerQueueMonitor class methodsFor:'defaults'!
|
|
67 |
|
|
68 |
defaultLabel
|
19282
|
69 |
^ 'TimerQueue Monitor'
|
19273
|
70 |
|
|
71 |
"Created: 23.1.1997 / 02:52:53 / cg"
|
|
72 |
! !
|
|
73 |
|
|
74 |
!TimerQueueMonitor class methodsFor:'menu specs'!
|
|
75 |
|
|
76 |
mainMenu
|
|
77 |
"This resource specification was automatically generated
|
|
78 |
by the MenuEditor of ST/X."
|
|
79 |
|
|
80 |
"Do not manually edit this!! If it is corrupted,
|
|
81 |
the MenuEditor may not be able to read the specification."
|
|
82 |
|
|
83 |
|
|
84 |
"
|
|
85 |
MenuEditor new openOnClass:TimerQueueMonitor andSelector:#mainMenu
|
|
86 |
(Menu new fromLiteralArrayEncoding:(TimerQueueMonitor mainMenu)) startUp
|
|
87 |
"
|
|
88 |
|
|
89 |
<resource: #menu>
|
|
90 |
|
|
91 |
^
|
|
92 |
#(Menu
|
|
93 |
(MenuItem
|
|
94 |
label: 'File'
|
|
95 |
submenuChannel: fileMenu
|
|
96 |
)
|
|
97 |
(MenuItem
|
|
98 |
label: 'View'
|
|
99 |
submenuChannel: viewMenu
|
|
100 |
)
|
|
101 |
)
|
|
102 |
! !
|
|
103 |
|
|
104 |
!TimerQueueMonitor methodsFor:'initialization'!
|
|
105 |
|
|
106 |
initialize
|
|
107 |
super initialize.
|
|
108 |
showTime := true.
|
|
109 |
! !
|
|
110 |
|
19282
|
111 |
!TimerQueueMonitor methodsFor:'menu'!
|
|
112 |
|
|
113 |
browseAction
|
|
114 |
self selectedEntriesDo:[:entry |
|
|
115 |
|action|
|
|
116 |
|
|
117 |
(action := entry at:'action' ifAbsent:[nil]) notNil ifTrue:[
|
|
118 |
|home mthd|
|
|
119 |
|
|
120 |
(home := action home) notNil ifTrue:[
|
|
121 |
(mthd := home method) notNil ifTrue:[
|
|
122 |
SystemBrowser default openInClass:mthd mclass selector:mthd selector
|
|
123 |
]
|
|
124 |
]
|
|
125 |
]
|
|
126 |
]
|
|
127 |
!
|
|
128 |
|
|
129 |
debugProcess
|
|
130 |
self selectedEntriesDo:[:entry |
|
19284
|
131 |
|process sema|
|
19282
|
132 |
|
19284
|
133 |
(process := entry at:'process' ifAbsent:[nil]) isNil ifTrue:[
|
|
134 |
(sema := entry at:'sema' ifAbsent:[nil]) notNil ifTrue:[
|
|
135 |
process := sema waitingProcesses firstIfEmpty:nil
|
|
136 |
]
|
|
137 |
].
|
|
138 |
process notNil ifTrue:[
|
19282
|
139 |
Debugger openOn:process
|
|
140 |
]
|
|
141 |
]
|
|
142 |
!
|
|
143 |
|
|
144 |
inspectProcess
|
|
145 |
self selectedEntriesDo:[:entry |
|
|
146 |
|process|
|
|
147 |
|
|
148 |
(process := entry at:'process' ifAbsent:[nil]) notNil ifTrue:[
|
|
149 |
process inspect.
|
|
150 |
]
|
|
151 |
]
|
|
152 |
!
|
|
153 |
|
|
154 |
inspectSemaphore
|
|
155 |
self selectedEntriesDo:[:entry |
|
|
156 |
|sema|
|
|
157 |
|
|
158 |
(sema := entry at:'sema' ifAbsent:[nil]) notNil ifTrue:[
|
19284
|
159 |
sema inspect.
|
19282
|
160 |
]
|
|
161 |
]
|
|
162 |
!
|
|
163 |
|
|
164 |
selectedEntriesDo:aBlock
|
|
165 |
|t sel|
|
|
166 |
|
|
167 |
[
|
|
168 |
t := timeouts copy.
|
|
169 |
sel := listView selection
|
|
170 |
] valueUninterruptably.
|
|
171 |
|
|
172 |
(sel ? #()) do:[:eachIndex |
|
|
173 |
|entry|
|
|
174 |
|
|
175 |
entry := t at:(eachIndex - self numberOfHeadlines) ifAbsent:[nil].
|
|
176 |
aBlock value:entry
|
|
177 |
]
|
|
178 |
!
|
|
179 |
|
|
180 |
statusMenu
|
|
181 |
"return a popUpMenu"
|
|
182 |
|
|
183 |
<resource: #programMenu>
|
|
184 |
|
|
185 |
|labels selectors m|
|
|
186 |
|
|
187 |
labels := resources array:#(
|
|
188 |
'Inspect Semaphore'
|
|
189 |
'Inspect Process'
|
|
190 |
'-'
|
|
191 |
'Debug Process'
|
|
192 |
'Browse Action'
|
|
193 |
).
|
|
194 |
selectors := #(
|
|
195 |
inspectSemaphore
|
|
196 |
inspectProcess
|
|
197 |
nil
|
|
198 |
debugProcess
|
|
199 |
browseAction
|
|
200 |
).
|
|
201 |
|
|
202 |
m := PopUpMenu labels:labels
|
|
203 |
selectors:selectors.
|
|
204 |
|
|
205 |
|
|
206 |
listView hasSelection ifFalse:[
|
|
207 |
m disableAll:#(
|
|
208 |
inspectSemaphore
|
|
209 |
inspectProcess
|
|
210 |
debugProcess
|
|
211 |
browseAction
|
|
212 |
)
|
|
213 |
].
|
|
214 |
^ m
|
|
215 |
|
|
216 |
"Modified: / 17-06-1998 / 14:17:05 / cg"
|
|
217 |
"Modified: / 23-02-2017 / 15:18:50 / stefan"
|
|
218 |
! !
|
|
219 |
|
19273
|
220 |
!TimerQueueMonitor methodsFor:'queries'!
|
|
221 |
|
|
222 |
numberOfHeadlines
|
|
223 |
^ 2 + (showTime == true ifTrue:1 ifFalse:0)
|
|
224 |
|
|
225 |
"Modified: / 29-10-2018 / 15:24:14 / Claus Gittinger"
|
|
226 |
! !
|
|
227 |
|
|
228 |
!TimerQueueMonitor methodsFor:'updating'!
|
|
229 |
|
|
230 |
titleLine
|
19355
|
231 |
^ 'When Process Action/Semaphore'.
|
19273
|
232 |
|
|
233 |
"
|
|
234 |
TimeQueueMonitor open
|
|
235 |
"
|
|
236 |
!
|
|
237 |
|
|
238 |
updateList
|
|
239 |
"update list of timeouts"
|
|
240 |
|
|
241 |
|newInfo t list|
|
|
242 |
|
|
243 |
shown ifTrue:[
|
|
244 |
newInfo := Processor timeoutList.
|
|
245 |
self updateStatus:newInfo
|
|
246 |
].
|
|
247 |
self installDelayedUpdate.
|
|
248 |
|
|
249 |
"Modified: / 29-10-2018 / 15:39:43 / Claus Gittinger"
|
|
250 |
!
|
|
251 |
|
|
252 |
updateStatus:newInfo
|
|
253 |
"update status display of timeouts"
|
|
254 |
|
19282
|
255 |
|numberOfHeadlines newTimeoutList oldList list
|
|
256 |
oldSelection newSelection osTimeStampOfList|
|
19273
|
257 |
|
|
258 |
newInfo isNil ifTrue:[^ self].
|
|
259 |
|
|
260 |
shown ifTrue:[
|
|
261 |
osTimeStampOfList := newInfo first.
|
|
262 |
newTimeoutList := newInfo second.
|
|
263 |
newTimeoutList sort:[:t1 :t2 | (t1 at:'time') < (t2 at:'time') ].
|
|
264 |
|
|
265 |
numberOfHeadlines := self numberOfHeadlines.
|
|
266 |
oldList := listView list.
|
19282
|
267 |
|
|
268 |
oldSelection := listView selection.
|
|
269 |
oldSelection notNil ifTrue:[
|
|
270 |
oldSelection := oldSelection
|
|
271 |
select:[:lNr | lNr > numberOfHeadlines]
|
|
272 |
thenCollect:[:lineNr |
|
|
273 |
timeouts at:(lineNr - numberOfHeadlines) ifAbsent:nil
|
|
274 |
].
|
|
275 |
newSelection := OrderedCollection new.
|
|
276 |
].
|
19273
|
277 |
|
|
278 |
list := OrderedCollection new:(newTimeoutList size + numberOfHeadlines).
|
|
279 |
(showTime == true) ifTrue:[
|
|
280 |
list add:'Time: ',(Time now printString).
|
|
281 |
].
|
|
282 |
list add:self titleLine.
|
|
283 |
list add:(String new:(self titleLine size+20) withAll:$-).
|
|
284 |
|
|
285 |
newTimeoutList notNil ifTrue:[
|
|
286 |
newTimeoutList do:[:aTimeout |
|
|
287 |
|time process processName action actionName sema semaName deltaTime
|
19282
|
288 |
color line millis|
|
19273
|
289 |
|
|
290 |
time := aTimeout at:'time'.
|
|
291 |
action := aTimeout at:'action'.
|
|
292 |
process := aTimeout at:'process'.
|
|
293 |
sema := aTimeout at:'sema'.
|
|
294 |
|
19283
|
295 |
process isNil ifTrue:[
|
|
296 |
sema notNil ifTrue:[
|
|
297 |
process := sema waitingProcesses firstIfEmpty:nil
|
|
298 |
]
|
|
299 |
].
|
|
300 |
|
19273
|
301 |
processName := process isNil ifTrue:[''] ifFalse:[process name].
|
|
302 |
actionName := action isNil ifTrue:[''] ifFalse:[action printString].
|
|
303 |
semaName := sema isNil ifTrue:[''] ifFalse:[sema displayString].
|
|
304 |
|
19282
|
305 |
millis := (time - osTimeStampOfList).
|
|
306 |
millis > 1000 ifTrue:[
|
|
307 |
millis > 2000 ifTrue:[
|
|
308 |
millis > 5000 ifTrue:[
|
|
309 |
millis := millis roundTo:500.
|
|
310 |
] ifFalse:[
|
|
311 |
millis := millis roundTo:100.
|
|
312 |
]
|
|
313 |
] ifFalse:[
|
|
314 |
millis := millis roundTo:10
|
|
315 |
].
|
|
316 |
].
|
|
317 |
deltaTime := TimeDuration milliseconds:millis.
|
19273
|
318 |
|
19284
|
319 |
line := (deltaTime printString) paddedTo:11.
|
19273
|
320 |
line := line , ' ' , ((processName contractTo:40) paddedTo:40).
|
|
321 |
action notNil ifTrue:[
|
19282
|
322 |
line := line , ' ' , (actionName contractTo:50) .
|
19273
|
323 |
] ifFalse:[
|
19282
|
324 |
line := line , ' ' , (semaName contractTo:50).
|
19273
|
325 |
].
|
|
326 |
|
|
327 |
"/ isOpen ifFalse:[
|
|
328 |
"/ color := Color red.
|
|
329 |
"/ ] ifTrue:[
|
|
330 |
"/ color := Color blue.
|
|
331 |
"/ ].
|
|
332 |
"/ line := line withColor:color.
|
|
333 |
|
|
334 |
list add:line.
|
19282
|
335 |
oldSelection notNil ifTrue:[
|
|
336 |
(oldSelection contains:[:tmo |
|
|
337 |
(tmo at:'process') == process
|
|
338 |
and:[ (tmo at:'action') == action
|
|
339 |
and:[ (tmo at:'sema') == sema ]]]
|
|
340 |
) ifTrue:[
|
|
341 |
newSelection add:list size.
|
|
342 |
]
|
|
343 |
]
|
19273
|
344 |
].
|
|
345 |
].
|
|
346 |
|
|
347 |
"avoid flicker"
|
|
348 |
(oldList notNil and:[oldList size == list size]) ifTrue:[
|
|
349 |
list keysAndValuesDo:[:idx :entry |
|
|
350 |
(oldList at:idx) ~= entry ifTrue:[
|
|
351 |
listView at:idx put:entry
|
|
352 |
]
|
|
353 |
]
|
|
354 |
] ifFalse:[
|
|
355 |
listView setList:list.
|
|
356 |
"the first few entries cannot be selected"
|
|
357 |
1 to:numberOfHeadlines do:[:lNr | listView attributeAt:lNr put:#disabled].
|
|
358 |
].
|
|
359 |
newSelection notNil ifTrue:[
|
|
360 |
listView selectWithoutScroll:newSelection
|
|
361 |
].
|
19282
|
362 |
listView flush.
|
|
363 |
timeouts := newTimeoutList.
|
19273
|
364 |
].
|
|
365 |
self installDelayedUpdate.
|
|
366 |
|
|
367 |
"Modified: / 11-10-2017 / 13:56:14 / cg"
|
|
368 |
"Modified: / 07-06-2019 / 22:10:36 / Claus Gittinger"
|
|
369 |
! !
|
|
370 |
|
|
371 |
!TimerQueueMonitor class methodsFor:'documentation'!
|
|
372 |
|
|
373 |
version_CVS
|
|
374 |
^ '$Header$'
|
|
375 |
! !
|
|
376 |
|