1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-28 16:00:22 +02:00

(Remembering During Operations): Refer to all "Guile

library functions" as provoking gc.
This commit is contained in:
Kevin Ryde 2003-06-21 23:02:58 +00:00
parent 1ebb8497cb
commit 7a52a21e96

View file

@ -46,7 +46,7 @@
@c essay @sp 10 @c essay @sp 10
@c essay @comment The title is printed in a large font. @c essay @comment The title is printed in a large font.
@c essay @title Data Representation in Guile @c essay @title Data Representation in Guile
@c essay @subtitle $Id: data-rep.texi,v 1.12 2003-06-13 23:32:33 kryde Exp $ @c essay @subtitle $Id: data-rep.texi,v 1.13 2003-06-21 23:02:58 kryde Exp $
@c essay @subtitle For use with Guile @value{VERSION} @c essay @subtitle For use with Guile @value{VERSION}
@c essay @author Jim Blandy @c essay @author Jim Blandy
@c essay @author Free Software Foundation @c essay @author Free Software Foundation
@ -1956,22 +1956,22 @@ value and the compiler will certainly keep it in a register or
somewhere throughout the routine. somewhere throughout the routine.
The @code{clear_image} example previously shown (@pxref{Type The @code{clear_image} example previously shown (@pxref{Type
checking}) did not use @code{scm_remember_upto_here_1}. This is checking}) didn't use @code{scm_remember_upto_here_1}. This is
because it didn't do anything that could result in a garbage collect. because it didn't do anything that could result in a garbage collect.
It's only in quite rare circumstances that a missing It's only in quite rare circumstances that a missing
@code{scm_remember_upto_here_1} will bite, but when it happens the @code{scm_remember_upto_here_1} will bite, but when it happens the
consequences are serious. Fortunately the rule is simple: whenever consequences are serious. Fortunately the rule is simple: whenever
allocating memory or doing something that might, ensure the @code{SCM} calling a Guile library function or doing something that might, ensure
of a smob is referenced past all accesses to its insides. Do this by the @code{SCM} of a smob is referenced past all accesses to its
adding an @code{scm_remember_upto_here_1} if there are no other insides. Do this by adding an @code{scm_remember_upto_here_1} if
references. there are no other references.
In a multi-threaded program, the rule is the same. As far as a given In a multi-threaded program, the rule is the same. As far as a given
thread is concerned, a garbage collect still only occurs within a thread is concerned, a garbage collect still only occurs within a
memory allocation function, not at an arbitrary time. (Guile waits Guile library function, not at an arbitrary time. (Guile waits for
for all threads to reach a memory function, and holds them there while all threads to reach one of its library functions, and holds them
the collector runs.) there while the collector runs.)
@node A Complete Example @node A Complete Example