CRITICAL_SECTION for set and get single bool value

前端 未结 4 1711
甜味超标
甜味超标 2021-01-19 11:20

now writing complicated class and felt that I use to much CRITICAL_SECTION.

As far as I know there are atomic operations for some types, th

4条回答
  •  梦谈多话
    2021-01-19 12:00

    Here this can be found:

    Simple reads and writes to properly aligned 64-bit variables are atomic on 64-bit Windows. Reads and writes to 64-bit values are not guaranteed to be atomic on 32-bit Windows. Reads and writes to variables of other sizes are not guaranteed to be atomic on any platform.

    Result should be correct but in programming it is better not to trust should. There still remains small possibility of failure because of CPU cache.

提交回复
热议问题