On Wed, Nov 3, 2010 at 6:28 PM, Michel Fortin <[email protected]>wrote:
> Le 2010-11-03 à 11:00, Max Samukha a écrit : > > > These notes on copy-constructible Qt types may be useful for the > > discussion: > > > > 1. 1/5 (approx. 100 classes) of all classes in core, gui, network, > webkit, > > svg and opengl packages define public copy-constructors. > > > > A half of those are in reference-counted COW types (approx. 50 classes). > The > > remaining 50 classes are reference-counted types without COW, types with > > allocating copy-constructors and types with trivial non-allocating > > constructors. > > > > Most of the types with allocating copy-constructors I would probably > > implemented as classes in D. Polymorphic types like QListWidgetItem that > > provide the copy-constructor only for clone() reimplementation should > > definitely be classes in D. > > This prompted me at looking into how reference counting works in Cocoa. > Note that all Cocoa objects use reference semantics and are reference > counted. > > The reference counter is not stored as part of the object. Instead, > reference counters are scattered among 8 global hash tables based on bits > 8,9,10 of the pointer value. Each table has its own spinlock which is used > for synchronization. On embeded system (iOS presumably), there is only one > hash table instead of 8. I guess having many tables is worthless if you have > only one core. > > I haven't done any benchmarking, but it seems the assumption is that each > thread will use a different memory region that will hopefully fall in a > different hash table and thus under a different spinlock and cacheline, > which should reduce contention. > > Relevant source code (under the Apple Public Source License): > > See function __CFDoExternRefOperation in > <http://www.opensource.apple.com/source/CF/CF-550/CFRuntime.c> > > Spinlock implementation it uses: > < > http://google.com/codesearch/p?hl=fr#pFm0LxzAWvs/darwinsource/tarballs/apsl/Libc-391.tar.gz%7Cz8mNFiEo9vA/Libc-391/i386/sys/OSAtomic.s&q=OSSpinLock%20package:darwin > > > > An interesting approach. I wonder how well it performs compared to traditional reference counters. > > -- > Michel Fortin > [email protected] > http://michelf.com/ > > > > _______________________________________________ > phobos mailing list > [email protected] > http://lists.puremagic.com/mailman/listinfo/phobos >
_______________________________________________ phobos mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/phobos
