Cross-platform (linux/Win32) nonblocking C++ IO on stdin/stdout/stderr

前端 未结 3 1743
南笙
南笙 2021-02-14 12:14

I\'m trying to find the best solution for nonblocking IO via stdin/stdout with the following characteristics:

  • As long as there is enough data, read in n-s
3条回答
  •  生来不讨喜
    2021-02-14 12:41

    I used the threads and platform specific code. See my answer to another question. I was able to put the OS-specific stuff in inputAvailable() (Linux uses select, Windows just returns true). I could then use WaitForSingleObject() with a timeout on Windows to try to let the thread complete, then TerminateThread() to kill it. Very ugly, but the team didn't want to use this bit of boost.

提交回复
热议问题