I am writing a simple console application in LInux/C++ that accepts user input from command line. I am using std::getline( std::cin ) / std::cin >> text
in a thread.
After 10 seconds I would like to stop accepting console input and write a text message then do other things. I am using a separate thread for the timer.
This approach doesn't work since I cannot check that 10 seconds have elapsed until the user has not inserted any text.
Is there any better way to stop the application accepting text and go to another piece of line? I was thinking to use settimer
and signals programming but I would like something to call from a different thread for simplicity.
Regards
AFG