Greg wrote:

> then the compiler may optimize this as:
> 
> wrlock
>    test if exists again
>    allocate element
>    insert element
>  >> race is here, prior to filling in element, another thread 
> may  >> read element, and use element that hasn't been filled in yet.
>    fill in element
> unlock
> 

This can not happen because no reader can hold the rdlock while a writer is
holding the wrlock no matter how the compiler optimize it.

Reply via email to