[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (guix git) and guile-git finalizers.
From: |
Mathieu Othacehe |
Subject: |
Re: (guix git) and guile-git finalizers. |
Date: |
Tue, 13 Jun 2017 18:39:12 +0200 |
User-agent: |
mu4e 0.9.18; emacs 25.2.1 |
Hi Andy,
> Nice sleuthing!
Thanks :)
>
> If you want to manually handle finalization at 'safe' points from
> Scheme, guardians are the things to use. Add your "finalizable" object
> to a guardian, and periodically "pump" the guardian to see if anything
> is finalizable; you can run the finalizer there.
So, the idea would be to create a global guardian with :
--8<---------------cut here---------------start------------->8---
(define pointer-guardian (make-guardian))
--8<---------------cut here---------------end--------------->8---
and replace those kind of functions :
--8<---------------cut here---------------start------------->8---
(define (pointer->commit! pointer)
(set-pointer-finalizer! pointer %commit-free)
(pointer->commit pointer))
--8<---------------cut here---------------end--------------->8---
by,
--8<---------------cut here---------------start------------->8---
(define (pointer->commit! pointer)
(pointer-guardian pointer)
(pointer->commit pointer))
--8<---------------cut here---------------end--------------->8---
But then, at shutdown, when I'll call (pointer-guardian) to get the list
of free-able pointers, how can I know that %commit-free has to be called
on commit pointers, %reference-free on reference pointers, ... ?
Thanks,
Mathieu