I'm attempting to get a curses application running in a threaded
environment to handle input with no delay. This is needed for
portability reasons. I have found though that in a threaded ruby
environment that whenever there is a call to sleep (even in a
different thread) then Curses behaves differently. The following code
acts as I expect it to:
ch = 
Curses::stdscr.nodelay = true
t = Thread.new do
x = 0
while c = Curses::stdscr.getch
break if c == 9 #tab exits
ch << [c]
It works just fine and grabs input with out waiting for it and returns
an error value when there is no input. If you change the line 'x = 0'
to 'sleep 1' then the behavior of Curses changes and the line c =
Curses::stdscr.getch will now sit idle until a key has been pressed.
Is there a better way of making threads idle other than sleep that
won't cause this side effect? Is there a better way of grabbing input
that the way that I am using?
Emachines M6805 (running in 32bit)