[cpp-threads] atomic operations package

Peter Dimov pdimov at mmltd.net
Fri Oct 14 11:15:50 BST 2005


jimmaureenrogers at att.net wrote:

> I do not see it. What happens when thread A is deleting an item while
> thread B is doing a find operation on that item? It appears to me
> that those are two incompatible concurrent operations. If the find
> reads a value during a delete operation the find operation may return
> an invalid or corrupted result.

Since C++ doesn't have garbage collection, the hash map unlinks but does not 
deallocate the erased nodes. My implementation "collects" the unreachable 
nodes when a thread obtains an exclusive lock on the map.

Concurrent data structures are much, much easier to write in Java, as it 
turns out. 




More information about the cpp-threads mailing list