Hi Evan,

You set up the loop but then starve it by going 100% CPU on the ``[ t ]
loop``, which never gives the scheduler green thread a chance to run.

Also, you should call ``flush`` so the terminal doesn't buffer all of the
output.

This one loops for awhile:

USING: kernel timers io io.servers prettyprint calendar namespaces
threads ;
IN: loopfun
: start-looping-timer ( -- timer )
  "Before Loop" . flush [ "Inside Loop" .  flush ] 2 seconds every ;

: endless-loop ( -- )
  start-looping-timer drop 10000 seconds sleep ;

MAIN: endless-loop

On Sun, Jul 26, 2015 at 11:49 AM, <evandib...@gmail.com> wrote:

>  What is the correct way to use a timer within a deployed program?
> I never get any errors, but the quotation of the timer is simply never
> called.
>
> ---------------
> USING: kernel timers io io.servers prettyprint calendar ;
> IN: loopfun
> : start-looping-timer ( -- timer )
>   "Before Loop" . [ "Inside Loop" .  ] 2 seconds every ;
>
> : endless-loop ( -- )
>   start-looping-timer [ t ] loop stop-timer ;
>
> MAIN: endless-loop
> ----------------
>
> Thanks,
> Evan
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to