[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: is there any timing class in the standard lib?

Daniel Sheppard

2/7/2007 5:21:00 AM

> ---------------------------
> class RSSdeamon
> def start
> puts "deamon started"
> while true
> sleep(5)
> puts "deamon running"
> end
> end
> end
>
> myProc = RSSdeamon.new()
> myProc.start
> ---------------------------
> It doesnt print even a single line. Am I missing something in
> concurrent
> programming?

No, but I'm guessing you're running windows and you're missing something
in IO flushing. stdout doesn't get flushed automatically by puts.

Try putting a STDOUT.flush after your puts.

2 Answers

Thai Le

2/7/2007 4:34:00 PM

0

Daniel Sheppard wrote:
>>
>> myProc = RSSdeamon.new()
>> myProc.start
>> ---------------------------
>> It doesnt print even a single line. Am I missing something in
>> concurrent
>> programming?
>
> No, but I'm guessing you're running windows and you're missing something
> in IO flushing. stdout doesn't get flushed automatically by puts.
>
> Try putting a STDOUT.flush after your puts.
Thanks man, it's working now. BTW, in the case of not using STDOUT, the
methd puts is actually executed but only the result is not printed out,
am i correct?

--
Posted via http://www.ruby-....

Paulo Köch

2/8/2007 2:19:00 AM

0

> Daniel Sheppard wrote:
>> Try putting a STDOUT.flush after your puts.

Some OSs, like linux, only flush the buffer to the target (STDOUT, in
this case) when the internal storage buffer is full or when a certain
event happens. Besides forcing flushing the buffer, One of this
events is, in many cases, the occurence of a "\n". At least, that's
my experience.

Paulo Jorge Duarte Köch
paulo.koch@gmail.com