Lisp HUG Maillist Archive

Usage about MP:MAP-ALL-PROCESSES and MP:MAP-PROCESSES?

Hi, Lisp-hug

It seems that MP:MAP-ALL-PROCESSES cannot work or I misuse it:

CL-USER 1 > (mp:ps)

#<MP:PROCESS Name "Cocoa Event Loop" Priority 60000000 State "Running">
#<MP:PROCESS Name "CAPI Execution Listener 1" Priority 0 State  
"Running">
#<MP:PROCESS Name "Editor Command Loop" Priority 20000000 State  
"Waiting for editor command">
#<MP:PROCESS Name "The idle process" Priority -536870912 State  
"Running (preempted)">
NIL

CL-USER 4 > (defvar *mp-names* nil)
*MP-NAMES*

CL-USER 5 > (mp:map-all-processes #'(lambda (x) (push (mp:process-name  
x) *mp-names*)))
#<MP:PROCESS Name "Cocoa Event Loop" Priority 60000000 State "Running">

CL-USER 6 > *mp-names*
("Cocoa Event Loop")

I think only the first process has been mapped by MP:MAP-ALL- 
PROCESSES, so does MP:MAP-PROCESSES. Do I miss something?

--
Chun Tian (binghe)
NetEase.com, Inc.
P. R. China






Re: Usage about MP:MAP-ALL-PROCESSES and MP:MAP-PROCESSES?

"Chun Tian (binghe)" <binghe.lisp@gmail.com> writes:

> I think only the first process has been mapped by MP:MAP-ALL-
> PROCESSES, so does MP:MAP-PROCESSES. Do I miss something?

I think there's some strangeness going on with the list you're
collecting into.  Possibly, push is not thread safe or something?  I
get the same results as you do on LWL 5.1, so it's not a mac thing.
But if I change your example slightly, I see that all the processes
are mapped:

CL-USER> (mp:map-all-processes 
          #'(lambda (p) (format t "~a~%" (mp:process-name p))))
Xt Event Loop for main
default listener process
EVAL server @ 23457
repl-thread
reader-thread
cron-in-lisp
control-thread
The idle process
NIL
CL-USER>

-- 
Mvh/Regards
Peder O. Klingenberg
Netfonds Bank ASA


Re: Usage about MP:MAP-ALL-PROCESSES and MP:MAP-PROCESSES?

"Chun Tian (binghe)" <binghe.lisp@gmail.com> writes:

> Hi, Peder
>
> Thanks. Actually before I ask on the list, I tried to print all
> process names by PRINC but didn't work: (never try FORMAT but you do
> and success ...)

Ah.  It has to do with the return value of the function.  Apparently,
mp:map-all-processes breaks early if you return non-nil:

CL-USER> (mp:map-all-processes
	  #'(lambda (p) (princ (mp:process-name p))))
Xt Event Loop for main
#<MP:PROCESS Name "Xt Event Loop for main" Priority 90000000 State "Xt event wait">
CL-USER> (mp:map-all-processes
	  #'(lambda (p) (princ (mp:process-name p)) nil))
Xt Event Loop for maindefault listener processEVAL server @ 23457repl-threadreader-threadcron-in-lispcontrol-threadThe idle process
NIL

-- 
Mvh/Regards
Peder O. Klingenberg
Netfonds Bank ASA


Re: Usage about MP:MAP-ALL-PROCESSES and MP:MAP-PROCESSES?

"Chun Tian (binghe)" <binghe.lisp@gmail.com> writes:

> Great! So it's a feature, not bug.

Could be, but in that case, it should be documented, IMO.

-- 
Mvh/Regards
Peder O. Klingenberg
Netfonds Bank ASA


Updated at: 2020-12-10 08:41 UTC