Hi Alexandre: On 24 Mar 2014, at 19:57, Alexandre Bergel <[email protected]> wrote:
> I am working on a memory model for expandable collection in Pharo. Currently, > OrderedCollection, Dictionary and other expandable collections use a internal > array to store their data. My new collection library recycle these array > instead of letting the garbage collector dispose them. I simply insert the > arrays in an ordered collection when an array is not necessary anymore. And I > remove one when I need one. Hm, is that really going to be worth the trouble? > At the end, #add: and #remove: are performed on these polls of arrays. I > haven’t been able to spot any problem regarding concurrency and I made no > effort in preventing them. I have a simple global collection and each call > site of "OrderedCollection new” can pick an element of my global collection. > > I have the impression that I simply need to guard the access to the global > poll, which is basically guarding #add: #remove: and #includes: One of the AtomicCollections might be the right things for you? > What is funny, is that I did not care at all about multi-threading and > concurrency, and I have not spotted any problem so far. There isn’t any ‘multi-threading’ like in Java, you got a much more control version: cooperative on the same priority, preemptive between priorities. So, I am not surprised. And well, these operations are likely not to be problematic when they are racy, except when the underling data structure could get into an inconsistent state itself. The overall operations (adding/removing/searing) are racy on the application level anyway. However, much more interesting would be to know what kind of benefit do you see for such reuse? And especially, with Spur around the corner, will it still pay off then? Or is it an application-specific optimization? Best regards Stefan > > Alexandre > > >> >> >> Best regards >> Stefan >> >> -- >> Stefan Marr >> INRIA Lille - Nord Europe >> http://stefan-marr.de/research/ >> >> >> >> > > -- > _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: > Alexandre Bergel http://www.bergel.eu > ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. > > > > -- Stefan Marr INRIA Lille - Nord Europe http://stefan-marr.de/research/
