Non-blocking keyboard input
Joe at bloow.edu
Joe at bloow.edu
Wed Dec 27 05:07:04 UTC 2023
??????????????????????????????????????? Surely there there is a
one liner library solution for this?
I have a program that spawns a thread for debugging information
and uses the keyboard input which allows me to display the
information.
If I use getchar or readline then it blocks the thread. This is
generally fine because that is all the thread does. The problem
is that it also blocks the program termination as the main thread
will not exit while the thread is running which is is because
it's waiting on keyboard input stuck on getchar or fgetc or
whatever.
If I terminate the threads using thread_term then it terminates
the program but the program then does not return the return code
that it was successfully finished(because it was prematurely
terminated by thread_term.
Surely there is some type of peek for keyboards in D? I can't
seem to get kbhit or because the library is not included(well, I
tried to use one from dmc but it seemed to be invalid. snn.lib
IIRC).
This shouldn't be hard... yet it is.
More information about the Digitalmars-d-learn
mailing list