This is the mail archive of the
mailing list for the Guile project.
Re: How to make user-defined functions abortable
- To: Lars Arvestad <firstname.lastname@example.org>
- Subject: Re: How to make user-defined functions abortable
- From: Mikael Djurfeldt <email@example.com>
- Date: 19 Aug 1999 18:38:14 +0200
- Cc: firstname.lastname@example.org
- Cc: email@example.com
- References: <firstname.lastname@example.org>
Lars Arvestad <email@example.com> 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.