Confirmed users, Bureaucrats and Sysops emeriti
1,217
edits
(gc api) |
|||
| Line 153: | Line 153: | ||
== GC == | == GC == | ||
''' | void '''gc_collect'''() | ||
Unconditionally collect garbage now. The current thread must be in a request. | |||
void '''gc_maybe_collect'''(int msecs) | |||
Suggest to the Garbage collector API that now might be a good time to collect garbage. The GC may decide to begin or continue incremental garbage collection during this callback. <var>msecs</var> is an application hint to the garbage collector indicating how many milliseconds incremental marking should be allowed to consume. There is no guarantee about the actual time consumed by the function. | |||
typedef enum gc_GCStatus { | |||
GC_ROOTING | |||
GC_PRE_SWEEP, | |||
GC_POST_SWEEP | |||
} gc_GCStatus; | |||
; GC_ROOTING | |||
: The callback function may programmatically "root" objects by explicitly marking objects (via <tt>gc_mark_object</tt>). | |||
; GC_PRE_SWEEP | |||
: At this point all marking has occurred. The callback function may synchronize external data structures by checking <tt>gc_get_markstate</tt> | |||
; GC_POST_SWEEP | |||
: At this point all sweeping has occurred, and the program is about to be resumed. | |||
typedef void (*gc_callback)( | |||
gc_GCStatus state); | |||
void '''gc_add_callback'''(gc_callback callback); | |||
== Rooting == | == Rooting == | ||