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: Bernd Paysan
Subject: Re: [gforth] Working example of tasker.fs use
Date: Sat, 13 Dec 2014 14:03:26 +0100
User-agent: KMail/4.14.3 (Linux/3.16.6-2-desktop; KDE/4.14.3; x86_64; ; )

Am Freitag, 12. Dezember 2014, 19:33:11 schrieb Jerry DeLisle:
> 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 ;

1 counter1 +!

would be more idiomatic.  And try to write a stack effect even for definitions 
where it is ( -- ).

> : start-task1 bg1 activate (task1) ;
> : start-task2 bg2 activate (task2) ;
> : 
> : show counter1 ? ."    " counter2 ? ;
> 
> Thanks much,
> 
> Jerry

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/




reply via email to

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