gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] Working example of tasker.fs use


From: Jerry DeLisle
Subject: Re: [gforth] Working example of tasker.fs use
Date: Fri, 12 Dec 2014 19:33:11 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 12/12/2014 02:47 PM, Bernd Paysan wrote:
Am Freitag, 12. Dezember 2014, 13:26:49 schrieb Jerry DeLisle:
The one example use of tasker.fs I have found does not work.

Can anyone point me to or provide a working example.

Regards,

Jerry

$1000 newtask constant test-task
: .x 10 0 do i . loop ;
: test test-task activate .x ;

Tried it:

test .x 00  11  22  33  44  55  66  77  88  99   ok

This also works with the unix/pthread.fs tasker (same API), but tasker.fs is
cooperative, unix/pthread.fs is using pthreads.


OK Got it figured out.

[IFDEF] my-code
  my-code
[ENDIF]
marker my-code
require tasker.fs

1000 newtask constant bg1
1000 newtask constant bg2

variable counter1
variable counter2

: (task1)  begin counter1 @ 1+ counter1 ! pause again ;
: (task2)  begin counter2 @ 1+ counter2 ! pause again ;

: start-task1 bg1 activate (task1) ;
: start-task2 bg2 activate (task2) ;

: show counter1 ? ."    " counter2 ? ;

Thanks much,

Jerry



reply via email to

[Prev in Thread] Current Thread [Next in Thread]