title: Some sort of Ruby "Interrupt"
body: <p>So here's what I'm doing -- I have a ruby script that prints out information every minute. I've also set up a proc for a trap so that when the user hits ctrl-c, the process aborts. The code looks something like this:</p>
  
  <pre><code>switch = true
  
  Signal.trap("SIGINT") do
      switch = false
  end
  
  lastTime = Time.now
  
  while switch do
      if Time.now.min &gt; lastTime.min then
          puts "A minute has gone by!"
      end
  end
  </code></pre>
  
  <p>Now the code itself is valid and runs well, but it does a lot of useless work checking the value of <code>switch</code> as often as it can. It uses up as much of the processor as it can get (at least, 100% of one core), so it's pretty wasteful. How can I do something similar to this, where an event is updated every so often, without wasting tons of cycles?</p>
  
  <p>All help is appreciated and thanks in advance!</p>