[Kst] : Huge performance problem under Windows

Peter Kümmel syntheticpp at gmx.net
Thu Nov 19 19:02:23 CET 2009


Barth Netterfield wrote:
> On November 19, 2009 12:10:57 pm Peter Kümmel wrote:
>> As I understand it the object store is not global, but
>> many classes have an instance of it (search for "ObjectStore *_").
> 
> Not formally, but it is effectively, since it can be gotten from anywhere via 
> the app/doc/etc.  As it is used as a global, It would be just as well, from my 
> point of view, to be done with all the _store pointers and make it a global.  
> There is only one of them after all.

You are right, I've commented out a 'virtual ObjectStore
*objectStore() const;'
declaration and get lots of compiler errors.

> 
>> Anyway, as you said, using reference counted pointers should make
>> ObjectStore superfluous. A container of refcounted pointers should be enough.
> 
> That is effectively what it is, with extra code globbed on to make adding and 
> removing things... worse?
> 
>> And I also don't like all the casting when getting a object from
>> the store, we are not using Java, with a master class 'Object', or
>> Objective-C with 'NSObject'.  One advantage of using C++ is to check at
>> compile-time for type-correctness not at runtime, with the help of
>> templates.
> 
> Most of the casting is related to finding all of the objects of a certain type.  
> Sometime you want
> 	All Objects
> or
> 	All Primitives 
> of
> 	All Scalars
> of
> 	All DataScalars
> 
> One list + dynamic casts makes this possible (if annoying).  Some of the 
> helper template functions in ObjectStore are designed to take care of this.

In principle the helper templates could only catch the null
returned from a dynamic_cast.

> 
>> A first fix would be to replace all ObjectStore member variables with
>> a container holding QSharedPtrs. This also makes the code more
>> readable.
> 
> ie, take stuff out of ObjectStore that doesn't belong there, 


Removing this function could be the first step:

template<class T>
SharedPtr<T> ObjectStore::createObject() {
  KstWriteLocker l(&(this->_lock));
  T *object = new T(this);
  addObject(object);

  return SharedPtr<T>(object);
}


> and use QT's lists
> as is.  I think we do want the template functions which return typed sub-
> lists.
> 
> I think we would prefer QExlicitlySharedPtrs though... what do you think?

For reference counting there is only QSharedPointer:
http://doc.qt.nokia.com/4.6-snapshot/qsharedpointer.html

For QExplicitlySharedDataPointer see my other mail.

Peter


More information about the Kst mailing list