On Fri, Oct 23, 2009 at 1:38 PM, Igor Stasenko <siguctua@gmail.com> wrote:
2009/10/23 Michael van der Gulik <mikevdg@gmail.com>:
A thread-safe collection package could have non-blocking implementations of most methods. Writing an object reference into an array should be an atomic operation and I assume most collections use Arrays for their implementation.
well, #basicAt:put: using a primitive, so its already atomic operation, given than VM doesn't running the code in multiple native threads.
So, there is no point in changing something for Arrays, and therefore no point to invent a non-blocking.. its already meets our demands.
Lets take a look at collections which doing something more sophisticated at #at:put:, like OrderedCollection or Dictionary. What kind of non-blocking we can introduce here? Dictionary may need to rehash the array due to growth.. OrderedCollection may also need to grow its storage (if you using #add: ) and such operations is far from being atomic. So, what kind of non-blocking you can invent here?
Checkmate; I can't think of any way of implementing a thread-safe growing/shrinking collection using only available atomic operations. There might be a way. I'll sleep on it. Gulik. -- http://gulik.pbwiki.com/