Sharing Ref Counted Containers
dsimcha
dsimcha at yahoo.com
Wed Aug 4 18:02:40 PDT 2010
I noticed that std.container.Array uses completely unsynchronized reference
counting. Does that mean that it's basically impossible to share it across
threads without introducing race conditions into the reference counting code,
even if you synchronize on other updates?
Are there any plans to make Array and future ref counted containers shareable?
If not (I'm not saying that making them shareable is necessarily worth
doing), I think there should be a large warning against casting these to
shared. Usually, when you cast a data structure to shared, you can write
working code as long as you properly synchronize all updates to the data
structure. However, because updates to the ref count field are happening
under the hood in an invisible fashion, no matter how properly synchronized
updates to the contents of the ref-counted container are, you basically can't
properly synchronize updates to the ref count field.
More information about the Digitalmars-d
mailing list