[D-runtime] A cooperative suspension API

Michel Fortin michel.fortin at michelf.com
Sat May 5 06:19:30 PDT 2012


Le 2012-05-05 à 0:45, Alex Rønne Petersen a écrit :

> (note that races in reading the variable are acceptable).
> 
>    private bool m_isCooperative;
> 
>    @property final bool isCooperative()
>    {
>        return m_isCooperative;
>    }

Even if races are acceptable, the code above is buggy. You need to make the read volatile if you don't want the compiler to optimize things by reading the variable only once when the function is inlined. (And I know volatile is deprecated.)


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/







More information about the D-runtime mailing list