weltyc/ntest — pull request #16 by vladpetric (2014-02-27 04:37:03+00:00)
Title: More de-windowzification of the code, together with a conversion of Game...

...X code from boost to c++11.

The flag I used is -std=c++0x. This way it works with gcc 4.6 (mingw is gcc 4.6)

One note about threading:

A thread reading on standard input can't be terminated properly. Threads can't really be killed, they need to be signaled and then they perform apoptosis themselves. Also, standard input can't be accessed in an asynchronous manner, unless some weird system-specific methods are used.

So, what's the problem? If I return from the main GameX method normally, the stdin thread is still running. Then, if the main function of the program returns conventionally, the runtime gets upset that a thread is still running. Then ntest would exit with an error message and the system log would mark the ntest app as crashed (minor nuisance really). My solution was to simply _exit(0) when responding to the quit command. I guess another solution would be to (also) stop the thread if it ever reads quit from stdin. A different threading setup, with the computation being done in a secondary thread and the main thread reading stdin might be better too.