ni: adds global references to Nit objects from C code
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 1 Mar 2012 23:29:06 +0000 (18:29 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 12 Apr 2012 19:38:15 +0000 (15:38 -0400)
commit1976fbdbffb7ca0effac6485fba1eaa2dbf86cb9
tree11983231ca2137d26befe5588615fb3f8d492712
parent032704d3a4cd2c43c01bd2fa5d7555fe254e8132
ni: adds global references to Nit objects from C code

Allows to preserve a reference during program execution. It is valid
no matter the extern method invoked.

Uses a global list to preserve all references explicitly asked to be
kept in the program. The user must call Object_incr_ref( Object obj )
to increment the reference count of obj. If it's reference count was
at 0, then it will be added to the global list.

The same Nit object may be present multiple times in the global list.
Only reference incrementation on the same C structure represernting
the object will increment the same counter.

This algorithm allows for fast increment, no matter how many global
references are already registered.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
clib/gc.c
clib/nit_common.h
clib/nit_main.c
src/native_interface/frontier.nit