|
Re: how many thread?!: msg#02383ruby-talk
Alfonso Caponi wrote: > Why? Timeout produces a new threads? Yes. $ less /usr/lib/ruby/1.8/timeout.rb ... def timeout(sec, exception=Error) return yield if sec == nil or sec.zero? raise ThreadError, "timeout within critical session" if Thread.critical begin x = Thread.current y = Thread.start { sleep sec x.raise exception, "execution expired" if x.alive? } yield sec # return true ensure y.kill if y and y.alive? end end module_function :timeout -- Posted via http://www.ruby-forum.com/.
|
|
||||||||||||||||||||||||||
| News | Mail Home | sitemap | FAQ | advertise |