From: Branden Tanga Date: 2010-05-31T03:25:05+09:00 Subject: Re: Interrupting the evaluation of a ruby script Disclosure: I have no experience with multi threading in ruby, but based on these parameters: * User can input a string of any length to be evaluated * User determines when to interrupt the evaluation You would need 2 threads, one to evaluate the string, and one to sit there active, waiting to process an interrupt. So there would be no need to "wake up" the 2nd thread, because it's always there, and always running. The performance hit for having multiple threads like this would be determined by how the ruby runtime takes advantage of multicore processors in different operating systems. Another concern that you must address, is how to determine which evaluation to apply an interrupt to. If you have 50 concurrent users, you would have 100 threads total. You would need to be sure to apply the correct interrupt to the correct thread. Perhaps a global hash which contains the id of the interrupt thread, and its corresponding evaluation thread. Then when an interrupt thread receives the proper input, it can look up its evaluation and send the interrupt command. In any case, performance tuning an multi threaded application is not easy. You might even have to look at alternative runtimes, like running it through jruby/tomcat to take advantage of java multi threading (assuming that jruby has the appropriate hooks into the jvm to accomplish such a thing). -- Posted via http://www.ruby-forum.com/.