On 15/11/2017 11:57 AM, Vladimirs Nordholm wrote:
Hello people from D-land.

To summarise my problem: I have a program in the terminal (Posix) with two threads: one which my main program is run on, and a second one which polls input via `poll(...)` and `read(...)`.

Let's call main thread T1, and a semi-blocking input-thread T2.

Every second T2 checks if T1 is terminated by checking if the a global flag is set to true. This is done with a `while(global_flag)`.

This feels to me like iffy code. So my question becomes: what is the best way to do this check with?

You're fine, a __gshared variable will do this nicely.

Reply via email to