[Pharo-dev] 11635: Race condition in SequenceableCollection>>shuffle
henrik.s.johansen at veloxit.no
Tue Oct 1 11:06:59 EDT 2013
On Sep 28, 2013, at 10:59 , Max Leske <maxleske at gmail.com> wrote:
> Thanks for the feedback guys.
> Based on the discussion I propose a different set of changes:
> ^ self shuffleBy: Random new
> ^ self copy shuffle
> 3. remove #shuffledBy: (if you're specific enough to use a custom Random instance you can also create a copy of the collection yourself if you want to)
> I leave the matter of renaming the methods for further discussion. Personally I'm for more intention revealing selectors; I quite like #shuffle and #shuffleInPlace. If we can agree on a different naming scheme we should then apply it to other methods aswell of course (e.g. #sort, #sortInPlace).
> Also open for discussion is the use of Collection>>randomForPicking and Collection>>mutexForPicking in other methods (such as #atRandom). I think it shouldn't be too big a problem to make those methods use individual Random instances and to remove the two class variables from Collection.
+1 from me on all three suggestions, as you might guess. :)
As for #atRandom using Random new, the performance hit and seed quality would be much greater concerns, as the Random instance would only be used once per invocation.
At this point in time there's no good alternatives to the current approach, but renaming the mutex/shared variable to reflect its singular use would be one possible improvement, I guess.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
More information about the Pharo-dev