Re: How to do atomic read?



On Jun 20, 9:11 am, "Alexander Grigoriev" <a...@xxxxxxxxxxxxx> wrote:
<0db...@xxxxxxxxx> wrote in message

But, in case I am not seeing the obvious, what's wrong with:

LONG asignee = InterlockedExchange(&var, var);

First, it's NOT atomic. There is a window for change. This IS atomic:

LONG asignee = InterlockedCompareExchange(&var, 0, 0);

Thanks for the correction. Can you explain why?

And what's Second?

Regards,
Don

.


Loading