This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to make user-defined functions abortable


Lars Arvestad <arve@nada.kth.se> writes:

> I have a small set of C functions that I have hooked into
> Guile. Unfortunately, they allocate lots of memory and take a long
> time to execute, and there are times when it would be nice to do C-c
> and abort the execution. Due to the allocated memory, I need to
> protect the functions in SCM_DEFER_INTS/SCM_ALLOW_INTS which blocks
> the possibility of using C-c. 

It is not a good idea to be a long time inside
SCM_DEFER_INTS/SCM_ALLOW_INTS, and I don't think it is necessary.

Why do you need this protection?

It should be possible to protect just certain critical operations.

(Also, it might be a good idea to do SCM_TICK once in a while so that
 threading will continue to behave well.)

If the reason for the protection is that you don't want to leak
allocated memory, I suggest that you put up an error handler using
scm_internal_catch which frees resources.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]