| 147 | std::thread *s_pThreadUserInput = nullptr; |
| 148 | |
| 149 | void LocalUserInput_Init() |
| 150 | { |
| 151 | s_pThreadUserInput = new std::thread( []() |
| 152 | { |
| 153 | while ( !g_bQuit ) |
| 154 | { |
| 155 | char szLine[ 4000 ]; |
| 156 | if ( !fgets( szLine, sizeof(szLine), stdin ) ) |
| 157 | { |
| 158 | // Well, you would hope that you could close the handle |
| 159 | // from the other thread to trigger this. Nope. |
| 160 | if ( g_bQuit ) |
| 161 | return; |
| 162 | g_bQuit = true; |
| 163 | Printf( "Failed to read on stdin, quitting\n" ); |
| 164 | break; |
| 165 | } |
| 166 | |
| 167 | mutexUserInputQueue.lock(); |
| 168 | queueUserInput.push( std::string( szLine ) ); |
| 169 | mutexUserInputQueue.unlock(); |
| 170 | } |
| 171 | } ); |
| 172 | } |
| 173 | |
| 174 | void LocalUserInput_Kill() |
| 175 | { |