Here the code of "mt01.rex":
say "--->" .context~name
trace r
t=.Test~new
t~m1-- same as: t~send('M1'), waits for return t~m2-- same as: t~send('M2'),
waits for return t~block-- wait for both methods to complete, -- same as:
t~send('BLOCK'), waits for return ::class Test-- a test class ::attribute
counter-- an attribute/an object variable ::method init-- constructor expose
counter-- must be very first statement trace a
say "arrived in:" .context~name
counter=0 ::method m1-- guarded method expose counter-- must be very
first statement trace a
counter+=1 -- increase counter say "arrived in:" .context~name"before
reply" reply tsk=1 2 -- to show up in trace ::method m2unguarded -- unguarded method trace a
say "arrived in:" .context~name"before reply" reply self~counter=self~counter-1
-- decrease counter ::method block-- block caller, if counter<>0 expose counter-- must be very
first statement guard on when counter=0 -- attribute used as control variable return 99
Trace output without thread number:
---> G:\tmp\orx\multithreading\mt01.rex
3 *-* t=.Test~new
15 *-* say "arrived in:" .context~name
arrived in: INIT
16 *-* counter=0
>>> "a TEST"
4 *-* t~m1 -- same as: t~send('M1'), waits for return
21 *-* counter+=1 -- increase counter
22 *-* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
23 *-* reply
5 *-* t~m2 -- same as: t~send('M2'), waits for return
28 *-* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
>I> Method "M1" with scope "TEST" in package
"G:\tmp\orx\multithreading\mt01.rex".
29 *-* reply
24 *-* tsk=1 2 -- to show up in trace
6 *-* t~block -- wait for both methods to complete,
>I> Method "M2" with scope "TEST" in package
"G:\tmp\orx\multithreading\mt01.rex".
30 *-* self~counter=self~counter-1 -- decrease counter
>>> "99"
Trace ouput with thread number:
---> G:\tmp\orx\multithreading\mt01.rex
3 *- 1* t=.Test~new
15 *- 1* say "arrived in:" .context~name
arrived in: INIT
16 *- 1* counter=0
>> 1> "a TEST"
4 *- 1* t~m1 -- same as: t~send('M1'), waits for return
21 *- 1* counter+=1 -- increase counter
22 *- 1* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
23 *- 1* reply
5 *- 1* t~m2 -- same as: t~send('M2'), waits for return
28 *- 1* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
>I 2> Method "M1" with scope "TEST" in package
"G:\tmp\orx\multithreading\mt01.rex".
29 *- 1* reply
24 *- 2* tsk=1 2 -- to show up in trace
6 *- 1* t~block -- wait for both methods to complete,
>I 3> Method "M2" with scope "TEST" in package
"G:\tmp\orx\multithreading\mt01.rex".
30 *- 3* self~counter=self~counter-1 -- decrease counter
>> 1> "99"
Multithreading trace output activated:
---> G:\tmp\orx\multithreading\mt01.rex
R1 T1 A1 3 *-* t=.Test~new
R1 T1 A2 V1 1* 15 *-* say "arrived in:" .context~name
arrived in: INIT
R1 T1 A2 V1 1* 16 *-* counter=0
R1 T1 A1 >>> "a TEST"
R1 T1 A1 4 *-* t~m1 -- same as:
t~send('M1'), waits for return
R1 T1 A3 V1 1* 21 *-* counter+=1 -- increase counter
R1 T1 A3 V1 1* 22 *-* say "arrived in:" .context~name "before
reply"
arrived in: M1 before reply
R1 T1 A3 V1 1* 23 *-* reply
R1 T1 A1 5 *-* t~m2 -- same as:
t~send('M2'), waits for return
R1 T1 A4 V1 1 28 *-* say "arrived in:" .context~name "before
reply"
arrived in: M2 before reply
R1 T2 A3 V1 1* >I> Method "M1" with scope "TEST" in package
"G:\tmp\orx\multithreading\mt01.rex".
R1 T1 A4 V1 1 29 *-* reply
R1 T2 A3 V1 1* 24 *-* tsk=1 2 -- to show up in
trace
R1 T1 A1 6 *-* t~block -- wait for both
methods to complete,
R1 T3 A4 V1 >I> Method "M2" with scope "TEST" in package
"G:\tmp\orx\multithreading\mt01.rex".
R1 T3 A4 V1 30 *-* self~counter=self~counter-1 --
decrease counter
R1 T1 A1 >>> "99"
---rony
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel