[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 3:34:00 AM

> 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?

If it's only going to do something every hour, are you sure you want a
daemon? Why not just have it run in a cron job (or scheduled task on
windows). If it's a daemon, it's going to sit there and consume memory
when it's not doing anything.

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.


1 Answer

Thai Le

2/7/2007 4:15:00 AM

0

Daniel Sheppard wrote:

> 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
---------------------------
It doesnt print even a single line. Am I missing something in concurrent
programming?

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