That helps very much, thank you both! 

Evan





From: John Benediktsson Sent: ‎Sunday‎, ‎July‎ ‎26‎, ‎2015 ‎3‎:‎28‎ ‎PM To: 
factor-talk@lists.sourceforge.net





Your ``[ t ] loop`` is a busy loop that will suck 100% CPU.



The problem you have is that a timer starts a new thread, and you want to wait 
forever just sleep the main thread?




    start-looping-timer 1 year sleep




I'm not sure if we have a way to wait for an existing thread to exit, but if we 
did, it would be something like:




    start-looping-timer thread>> wait-for-thread




If you have trouble seeing the output of your timer, that is because the timer 
thread is created knowing only about the global namespace, so if you want to 
output to the stream you started it from:




    : start-looping-timer ( -- timer )

        output-stream get '[
            _ [ "Inside Loop" . ] with-output-stream*
        ] 2 seconds every ;




Hope that helps!









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