RE: [GD-Windows] Stopping a thread cleanly
Brought to you by:
vexxed72
|
From: Brian S. <bs...@mi...> - 2002-02-18 16:59:50
|
> > In this case the compiler could put bExit in a register due
> > to optimisation which obviously isn't good.
>=20
> This is actually why this came up. When I looked at my original code,
> it was basically doing this:
>=20
> while ( 1 )
> {
> ...
> if ( pData->bKill )
> break;
> ...
> }
>=20
> I was more than a little concerned that the compiler wasn't reloading
> pData->bKill in some instances, because there were sections of code
> where no function calls were occurring but bKill was being checked
> multiple times.
>=20
The compiler should always reload it unless you've specified "assume no
aliasing" (which is not the default, even in optimized builds). Since
it's not a local variable, it has to assume that pData->bKill can be
changed every time through the loop.
--brian
|