Johannes Sixt wrote:
> On Wednesday 07 March 2007 19:25, Christian Thaeter wrote:
>>> Remove the Garbage collector in favor of boost::shared_ptr, the GC has
>>> some nasty bugs, partially together with threads. By replacing ALL
>>> Asset* with boost::shared_ptr<Asset> these should be fixed on expanse of
>>> some performance.
> 
> Is boost::shared_ptr thread safe? If not, this replacement does not fix 
> anything, in particular not the thread related bugs.

http://www.boost.org/libs/smart_ptr/shared_ptr.htm#ThreadSafety

so its not fully, but it employs the locking which already exists.

The only problem could be when the internal use-count drops to zero and
the thread prepares to delete a object, if then a context switch occurs
and another thread increments the use count to 1 we have a problem.
But this case is avoided because ALL pointers are shared pointers now.
This costs little performance but guards against that case.

I have Cinelerra running under valgrind for hours here now, loading some
hundred assets and valgrind didnt report a single error with asset
handling, thats at least far better than before :).

Even if there is some corner case left where thread safety play against
us, it's now possible to replace the shared_ptr easily with something
else. But as long I don't observe such glitches I concentrate on
improving a debugging frameworks which aids in finding race conditions,
deadlocks and unspecified ownership of objects.

The shared_ptr transistion is only a prelimary step, somewhat better
than a bandaid to fix some bugs, later to be optimized mostly out again.

        Christian

_______________________________________________
Cinelerra mailing list
Cinelerra@skolelinux.no
https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra

Reply via email to