multithreading - How to create a resetable "process" or "thread" in Ruby? -


I've got this script, which uploads some files, connects via SS and something on remote server It does, like some kind of deployment script, and I want to run it whenever it wants to run and want to be able to reset it in the middle of processing.

  DEF deployment # kill some stuff here end def do_deploy $ deploy! If $ $ Deployed = Thread.N.N {Deployed} $ Deployment # When I am not included here, it stops execution of the deployment # First when the thread switches to someone else, and # then does not end the reading = threads.new while the line = gets.chomp do it! "Line" when "q" comes out of the "exit" thread.Exit, then "r" occurs when do_deploy end-end readings. Join  

Even if $ deploy.join executes the entire deployment thread, it prevents any input from reading, so I reset it between execution can not do. And I can not include it at the end of the script.

What I need to do, it's to run the job while listening to the input and be able to kill and restart the process at any time or even better , Send it a message that will be processed immediately, like short-down trial execution . I know that killing the threads is not really a systematic, but in this case, I do not think this is a big issue.

I also want to say, that I am working on Windows, so I do not have the fork () available.

Is there any other way to solve the thread without it?

Edit: Just got to know that calling becomes until other input is given, other threads from execution. In this example

  t1 = thread.nu {10.times {| I | When i  returns   

T1 to some code then } T2 = Thread.new {puts gets} t1.join t2.join < / Code>

code>. It just sits for ever, how should I read from the input without blocking all the sources?

Edit2: Just got to know that this is a

Edit 3: Problem gets removed in JRuby or ruby ​​1.9

< Use the JRuby in it. There are real threads in it and do not hunt GIL (Global Interpreter Lock) which is near the Ruby Interputer.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -