On Sat, Jun 30, 2007 at 04:52:53PM +0000, Sandro Santilli wrote: > CVSROOT: /sources/gnash > Module name: gnash > Changes by: Sandro Santilli <strk> 07/06/30 16:52:53 > > Modified files: > . : ChangeLog > libbase : ref_counted.h smart_ptr.h > > Log message: > * libbase/ref_counted.h: remove inheritance of ref_counted > from GcResource, provide temporary isReachable/setReachable > to allow not reverting all GC-related additions to character > definitions and other possibly GcResource objects. > * libbase/smart_ptr.h: have two versions of the intrusive_ptr > free functions: one for GcResource (do nothing) and one > for ref_counted (add/drop ref). Enable GC by default, where > current version uses both RC and GC (GC only used for > as_object)
With this commit I splitted ref_counted and GcResource so that they are not in the same inheritance tree. This allows us to choose which classes will be managed with a reference-counting model and which one with a garbage-collector one. The rationale was to make threading safe, starting with the assumption that the loader/parser thread should never create as_object instances. The previous problem was that the loader thread was creating GcResource instances (character_def in particular) concurrently with a running GC, thus resulting in premature deletion of just-created objects. See http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Stop-the-world_vs._incremental_vs._concurrent for a description of the problem. So, with this patch, we keep character_def as a ref-counted class, as well as bitmap_info, which were the ones I didn't really like to have garbage-collected. The implementation is an hack to allow touching the less files possible. We still always use intrusive_ptr for both ref_counted and GcResource classes, but the intrusive_ptr_add_ref and intrusive_ptr_release free functions will act differently based on what type they are working on: they do NOTHIN for GcResource and do the normal add/drop ref calls for ref_counted. The GNASH_USE_GC macro is now defined by default, which means as_object are garbage-collected. Undefining that macro in libbase/smart_ptr.h would bring us back to ref_counted as_objects. All the rest should be the same. Next step would be validating this model and if we like it decide which syntax we want to use for garbage collected pointers. There's technically NO NEED to store garbage-collected pointers into a smart pointer, but might come handy to use a smart pointer for clarity and eventually reducing errors by disallowing explicit deletion, or other similar things. Tests welcome. --strk; _______________________________________________ Gnash-commit mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnash-commit
