From: Tony Arcieri Date: 2009-06-10T08:37:49+09:00 Subject: Re: doing something each second --00163662e63d9d0299046bf2d869 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Tue, Jun 9, 2009 at 3:08 PM, Christoph Jasinski < christoph.jasinski@googlemail.com> wrote: > Thanks to all of you. I actually started out using a thread but then got > into some trouble, which some people helped me to solve. I was just > thinking > that there might be a way of using Time.second.each do {....} because I saw > 5.times do {...}. That was just a "creative" conclusion. > Chris > You could do something like this with an asynchronous event framework like EventMachine or Rev without using a thread, although if what you're trying to do every second takes longer than a second you will likely get... strange behavior. Here's an example with Rev: class MyTimer < Rev::TimerWatcher def on_timer do_something end end watcher = MyTimer.new(1, true) # 1 second repeating watcher.attach Rev::Loop.default Rev::Loop.default.run -- Tony Arcieri medioh.com --00163662e63d9d0299046bf2d869--