From: Mike Gran <spk121@yahoo.com>
To: Guile User <guile-user@gnu.org>
Subject: atexit in modules
Date: Wed, 12 Nov 2008 21:59:56 -0800 (PST) [thread overview]
Message-ID: <677173.17745.qm@web37908.mail.mud.yahoo.com> (raw)
I have a C library that I wrapped as gsubrs that get put into a Guile module. The C library wants a library_init() function called when it is initialized and a library_end() function called when it taken down.
(for the curious, it is specifically mysql_library_init() and mysql_library_end().)
The library_init() call is easy because it can be called automatically in the initialization function called by (load-extension "libfoo.so" "foo_init").
Since libraries are never unloaded, I guess I can wait until the program exit to call library_end().
I read this thread
http://thread.gmane.org/gmane.lisp.guile.user/6430/focus=6443
This suggests dynamic-wind is the way to go, but, I don't think it would work in my case because I want to keep this in a Guile wrapper module that gets loaded with use-module.
I've got one crazy idea. I could create a new special SMOB type which calls library_end() as part of the SMOB's free function. When the Guile library is loaded, it will define a single variable of that type in the module's environment.
But then I started think about what happens if the module is used in multiple threads, and it made my head hurt.
Any better ideas?
-Mike Gran
next reply other threads:[~2008-11-13 5:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-13 5:59 Mike Gran [this message]
2008-11-13 19:26 ` atexit in modules Ludovic Courtès
2008-11-13 19:59 ` Mike Gran
2008-11-14 2:27 ` Mike Gran
2008-11-16 0:27 ` Neil Jerram
2008-11-16 3:26 ` Mike Gran
2008-11-17 0:00 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=677173.17745.qm@web37908.mail.mud.yahoo.com \
--to=spk121@yahoo.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).