[Gc] Patch resubmission: Default stop_func

Ivan Maidanski ivmai at mail.ru
Fri Sep 11 06:32:01 PDT 2009


This suggested patch (ivmai129.diff), superseding diff47 [Nov 20], introduces the default stop_func used on implicitly trigged collections (unless handling OOM, of course). For more info, see (the first 2 paragraphs): https://permalink.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2513

Note: the default stop_func is also used for GC_gcollect() - this is a bit arguable but I think it's more logical (explicit fn is used for GC_try_to_collect(), implicit default stop_func is used for collections trigged by other means) and more useful (eg., a timeout policy could be introduce to an existing application by just adding GC_set_stop_func(fn) instead of replacing all GC_gcollect() calls with something like GC_try_to_collect(GC_get_stop_func())).

ChangeLog entries:

	* alloc.c (GC_default_stop_func): New static variable (initialized
	to GC_never_stop_func).
	* alloc.c (GC_set_stop_func, GC_get_stop_func): New function.
	* alloc.c (GC_timeout_stop_func): Define as GC_default_stop_func
	(instead of GC_never_stop_func) if SMALL_CONFIG (or NO_CLOCK),
	else call GC_default_stop_func() before getting "current_time".
	* alloc.c (GC_maybe_gc): Expand GC_gcollect_inner() macro (for
	FIXME comment).
	* alloc.c (GC_maybe_gc, GC_collect_a_little_inner): add FIXME for
	replacing GC_never_stop_func with GC_default_stop_func (if
	* alloc.c (GC_gcollect): Use GC_default_stop_func.
	* alloc.c (GC_collect_or_expand): Use GC_default_stop_func
	(instead of GC_never_stop_func) unless it is trigged due to out of
	memory; don't increment GC_fail_count and don't output warning
	(before trying to collect again) in case the collection has been
	interrupted (by GC_default_stop_func) and the heap expansion has
	failed too.
	* include/gc.h (GC_set_stop_func, GC_get_stop_func): New function

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ivmai129.diff
Type: application/octet-stream
Size: 4432 bytes
Desc: not available
Url : https://napali.hpl.hp.com/pipermail/gc/attachments/20090911/7237a82d/ivmai129-0001.obj

More information about the Gc mailing list