mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
Use smobs as an example for 'remembering'. Mention continuation barriers.
This commit is contained in:
parent
a0f78c5085
commit
384138c496
1 changed files with 12 additions and 7 deletions
|
@ -246,13 +246,13 @@ wanted.
|
||||||
|
|
||||||
There are situations, however, where a @code{SCM} object needs to be
|
There are situations, however, where a @code{SCM} object needs to be
|
||||||
around longer than its reference from a local variable or function
|
around longer than its reference from a local variable or function
|
||||||
parameter. This happens, for example, when you retrieve the array of
|
parameter. This happens, for example, when you retrieve some pointer
|
||||||
characters from a Scheme string and work on that array directly. The
|
from a smob and work with that pointer directly. The reference to the
|
||||||
reference to the @code{SCM} string object might be dead after the
|
@code{SCM} smob object might be dead after the pointer has been
|
||||||
character array has been retrieved, but the array itself is still in use
|
retrieved, but the pointer itself (and the memory pointed to) is still
|
||||||
and thus the string object must be protected. The compiler does not
|
in use and thus the smob object must be protected. The compiler does
|
||||||
know about this connection and might overwrite the @code{SCM} reference
|
not know about this connection and might overwrite the @code{SCM}
|
||||||
too early.
|
reference too early.
|
||||||
|
|
||||||
To get around this problem, you can use @code{scm_remember_upto_here_1}
|
To get around this problem, you can use @code{scm_remember_upto_here_1}
|
||||||
and its cousins. It will keep the compiler from overwriting the
|
and its cousins. It will keep the compiler from overwriting the
|
||||||
|
@ -383,6 +383,11 @@ corresponding @code{scm_internal_dynamic_wind} function, but it might
|
||||||
prefer to use the @dfn{frames} concept that is more natural for C code,
|
prefer to use the @dfn{frames} concept that is more natural for C code,
|
||||||
(@pxref{Frames}).
|
(@pxref{Frames}).
|
||||||
|
|
||||||
|
Instead of coping with non-local control flow, you can also prevent it
|
||||||
|
by errecting a @emph{continuation barrier}, @xref{Continuation
|
||||||
|
Barriers}. The function @code{scm_c_with_continuation_barrier}, for
|
||||||
|
example, is guaranteed to return exactly once.
|
||||||
|
|
||||||
@node Asynchronous Signals
|
@node Asynchronous Signals
|
||||||
@subsection Asynchronous Signals
|
@subsection Asynchronous Signals
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue