From: "Brian Schröder" Date: 2005-04-26T02:07:35+09:00 Subject: Re: thread question On 25/04/05, Joe Van Dyk wrote: > On 4/25/05, Brian Schr�der wrote: > > On 25/04/05, Joe Van Dyk wrote: > > > Every second, a function in the class that's being made available via > > > DRb should be called automatically. How would I do that? > > > > > > So I'd have > > > > > > class Server > > > def update > > > # stuff gets updated > > > end > > > end > > > > > > server = DRb.start_service.... > > > > > > server.update() # <== somehow ran every second > > > > How about: > > > > update_thread = Thread.new(server) do | s | > > loop do > > sleep 1 > > s.update > > end > > end > > > > > > > > DRb.thread.join > > > > > > > > > > or is there anything special with drb that prohibits this? > > > > I wasn't sure about how the interactions between the threads would > work. I'll try the above and see how it works. > > One difference from your whish is, that this calls the function with a sleeptime of approximately one second, or sometimes more, and not every second. Calling it every second is more difficult. Also, if I remember correctly, ruby threads may be blocked for some time by some large io activities. hope to help, Brian -- http://ruby.brian-schroeder.de/ multilingual _non rails_ ruby based vocabulary trainer: http://www.vocabulaire.org/ | http://www.gloser.org/ | http://www.vokabeln.net/