is there any timing class in the standard lib?

T

Thai Le

Hi guy,
I 'm doing a deamon that call a method every hour. Is there any class in
the standard library that I can use for counting the time?
Thai
 
T

Thai Le

Daniel said:
If you really want your process to sit around, either use sleep(60*60)
or if you need more accuracy than that, do some calculations with
DateTime to figure out how long it will be till the next hour mark.

Thanks 4 your advice but this's part of the requirements, I have no
access to system util. For testing, i try
---------------------------
class RSSdeamon
def start
puts "deamon started"
while true
sleep(5)
puts "deamon running"
end
end
end

myProc = RSSdeamon.new()
myProc.start
 
T

Thai Le

Daniel said:
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?
 
P

Paulo Köch

Some OSs, like linux, only flush the buffer to the target (STDOUT, in =20=

this case) when the internal storage buffer is full or when a certain =20=

event happens. Besides forcing flushing the buffer, One of this =20
events is, in many cases, the occurence of a "\n". At least, that's =20
my experience.

Paulo Jorge Duarte K=F6ch
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top