On Fri, Oct 23, 2009 at 11:23 AM, Igor Stasenko <[email protected]> wrote:
> 2009/10/23 Schwab,Wilhelm K <[email protected]>: > > Hello all, > > > > I just looked around for thread-safe collections, and found nothing that > looks like a shared dictionary. The squeak-dev archives contain the > obligatory newbie posts (wanting all collections to be thread safe) and the > expected replies, some of which are overly dismissive of the idea. > Something that protects things like #at:ifAbsentPut: and friends is > _really_ useful. Am I missing an existing implementation? > > > > Imo, there's only one shared collection which is useful - shared queue. :) > If you need more kinds of thread-safe collections, it probably > indicating that the concurrent code (or model) which you designed is > in pretty bad shape. > > Just compare two following snippets: > > 1 to: 100 do: [:i | collection threadSafeAt: i put: something]. > > and: > > semaphore critical: [ 1 to: 100 do: [:i | collection at: i put: something] > ]. > > What you think, which one is better? > > 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. Gulik. -- http://gulik.pbwiki.com/
_______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
