From: Jason Vinson Date: 2006-09-10T01:20:29+09:00 Subject: Re: Timer Task? Hi Matt, Thanks for the reply. I am trying to schedule a recurring task, so it would run constantly. I guess my real question is the preferred approach something like this? notifier = SnarlMail.new("imap.mailserver.com", "username", "passwd") while(true) do notifier.check sleep 60 end Does sleep cost anything in terms of resources, and if so what is "cheaper"? Thanks, Jason -----Original Message----- From: Matt Todd [mailto:chiology@gmail.com] Sent: Saturday, September 09, 2006 12:04 PM To: ruby-talk ML Subject: Re: Timer Task? > I'm writing my first real ruby utility on my own (using the snarl library > http://www.fullphat.net/ plus http://code.google.com/p/ruby-snarl/ and > net/imap for new mail notification), and it's working fine, other than the > fact that I don't know how to schedule a recurring job. I'm looking for > something similar to the Timer class in java for scheduling jobs in ruby. > Is there such a thing in the core api? This doesn't answer your question, but, is your utility actually a full-fledged client? Or just what someone would use to send off emails/notifications once per session. My point is, does this utility run constantly? Or just once when needed? If you leave it running constantly, I think you already have a main loop going on, so why not have a little method to handle scheduled/recurring events at whatever interval you do have? Maybe if you could clarify a little better... I must admit, though, that this is far from my expertise, and perhaps someone with a little more experience with this kind of thing would be able to help you far better! (But I'm trying!) M.T.