Jason Vinson wrote:
I guess my real question is the preferred approach
something like this?
notifier = SnarlMail.new("imap.mailserver.com", "username", "passwd")
Does sleep cost anything in terms of resources, and if so what is
AFAIK "sleep" is a perfectly adequate way to idle a thread, and it has the
advantage of being trivial to implement. I have recently seen Ruby threads
that used "sleep" be idled by the thread manager, never to be called again,
but this has to do with Ruby threads within a Ruby process, not native
threads represented by particular Ruby applications.
Have you considered using OS-specific facilities like "cron" instead of
"sleep" for scheduling? I use cron for most of these periodic, relatively
low-powered tasks because it is easy to add a task to cron's list of jobs,
and it burdens the system less than maintaining a bunch of sleeping
processes -- cron loads, runs, and unloads its tasks, while a sleeping
process represents an ongoing use of resources.
From: Paul Lutus [mailto:email@example.com]
Sent: Saturday, September 09, 2006 1:20 PM
To: ruby-talk ML
Subject: Re: Timer Task?
Thanks for the reply Paul,
The main reason for maintaining a Thread is because there's a tiny bit of
state involved (I only want to report new mail, not the same new mail over
and over again). I'm open to other alternatives, but writing out to the
file system seems like the only other option, which I'd prefer not to do.