L
Lars Uffmann
In an event routine, I want to end a certain thread. I am setting a flag
that is checked by the thread and causes it to end, when it is set. Then
the thread sets a "response" flag, just before exiting. In the event
routine, I would like to wait for that response flag, because at that
point, I can be sure that the old thread (even if it still is alive
between setting the response flag and exiting) will no longer interfere
with a subsequent call.
However, a
while (!responseflag);
heavily blocks system resources and apparently also the read call blocks
the writing of the responseflag - I get caught in an endless loop there.
while (!responseflag) cout << "." << endl;
seems to do the job, with a random amount of periods printed to stdout,
but I wouldn't rely on it always working. So what is the thing to do
within that while loop?
TIA!
Lars
that is checked by the thread and causes it to end, when it is set. Then
the thread sets a "response" flag, just before exiting. In the event
routine, I would like to wait for that response flag, because at that
point, I can be sure that the old thread (even if it still is alive
between setting the response flag and exiting) will no longer interfere
with a subsequent call.
However, a
while (!responseflag);
heavily blocks system resources and apparently also the read call blocks
the writing of the responseflag - I get caught in an endless loop there.
while (!responseflag) cout << "." << endl;
seems to do the job, with a random amount of periods printed to stdout,
but I wouldn't rely on it always working. So what is the thing to do
within that while loop?
TIA!
Lars