I'm currently evaluating my options in terms of implementing a non-blocking input stream. I'm unsure as to what other options I may have available. The output stream needs to stay blocked.
Requirements are portability across windows and linux. Mac would be nice too.
Minimal conditional compilation is acceptable too. Although not desirable.
My current options are:
Boost::threads - Implement the input stream here, outside of the main thread. The only point of contact between both threads is a command queue. The input thread only pushes onto the queue. It doesn't manage it in any other way neither it concerns itself with the queue contents. The main thread listeners will pop the command queue and implement a sort of event-driven console application. However I do need the output stream on the main thread to block. So this does complicate thread management.
Boost::asio - Maybe a little overkill for this. And I'm not even sure I can use it. However my program already depends on boost::asio.
ncurses - using such functions as cbreak, halfdelay and nodelay, I can turn off the tty buffers and implement a non blocking input. My program already depends on ncurses for screen layout, so this becomes only a implementation decision. However this method is crude and complicates user input management.
I'm biased towards threads. Seems the easiest and most solid solution. But if you know of a better way to implement non-blocking input/blocked output in a console, please let me know.