On Monday, 11 April 2016 at 14:53:31 UTC, Adam D. Ruppe wrote:
On Sunday, 10 April 2016 at 08:29:22 UTC, Lass Safin wrote:
Thus, my question is: Is there any way to cancel the read from stdin prematurely from another thread, so that the thread can finish?

What operating system are you on?

I wouldn't be using threads for this at all, you might want to reorganize the program to get terminal events sent to the same gui event loop so exiting it would exit all of it.

But failing that, canceling an I/O request can be done by sending yourself a signal on posix and on Windows there's a system API call that one thread can cancel another thread's blocking read.

The D library would see these cancels as an error and throw an exception. You could catch it or let it kill the thread, since you want to exit anyway.

My savior!
I can't put it in one loop, since the window also has some autonomous features.

Reply via email to