Thread safety of AAs
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue May 15 20:03:54 PDT 2012
On Wed, May 16, 2012 at 04:35:17AM +0200, Alex Rønne Petersen wrote:
> Hi,
>
> Suppose that I have an AA that I'm doing lookups on from one thread,
> and writing to in another. Is this safe at all? Naturally, I'm
> willing to accept the data races involved, but the question is
> whether the concurrent lookup + mutation is guaranteed to be safe.
[...]
Safe as in, no memory corruption? Or safe as in, the data will be
consistent (barring any data races)?
Memory safety I'm not sure, I _think_ it might be safe, but I have my
doubts; data consistency, likely not, because you could potentially be
reading partially-copied data (say the mutator was assigning new data to
an existing key and the reader is reading that same data
simultaneously; you may be seeing a partial copy of the new data
intermixed with the old data).
T
--
Just because you survived after you did it, doesn't mean it wasn't stupid!
More information about the Digitalmars-d-learn
mailing list