ueforth icon indicating copy to clipboard operation
ueforth copied to clipboard

Extra task words

Open Eszartek opened this issue 2 years ago • 0 comments

I'm not sure of the usefullness of these words, but it was fun trying to figure them out.

stop-task will stop a running task. It's actually a suspend, as you can restart the task and then the stopped task will continue where it left off. It just takes the task out of the circular task list. ie: mytask stop-task

: stop-task ( t -- ) task-list @ begin 2dup @ = if swap @ swap ! exit then @ dup task-list @ = until ;

.ts works like .s but for a task. If your task has a pause in it to allow the webui to stay responsive, then .ts will show the stack at the pause and print the name of the next word after the pause. If I have multiple pauses, then I usually define empty marker words like : mark1 ; and place this after each pause so that .ts will indicate at which mark it is at, using a different mark word for each pause. ie: mytask .ts

: tdepth ( t -- n ) dup 4 + @ swap 8 +  - cell/ ;  ( current stack depth for a task )
: .ts ( t -- ) dup dup ." <" tdepth 1 - n. ." > " tdepth 0 max for aft dup 4 + @  r@  cells - @ r@ 0= if ."  -> " @ @  >name type else . then then next drop ;

Output example: <4> 2 66 7 1 -> mark1

Eszartek avatar Nov 17 '22 19:11 Eszartek