guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libguile thread safety


From: Panicz Maciej Godek
Subject: Re: libguile thread safety
Date: Sun, 5 Jan 2014 14:15:42 +0100

2014/1/5 Chris Vine <address@hidden>:

> I actually have a prototype working well now, apart from the module
> issue Mark Weaver referred to, which I have to say has not yet bitten me
> but no doubt might.

If you are worried about this, you could try to take your own
precautions and redefine the "use-modules" syntax (or others, like
"resolve-module", if you are planning to use them) to make sure that
it is thread safe.

The sole act of redefinition would require you to create a new module like this:
(define-module (safe-modules)
  #:use-module (ice-9 format)
  #:replace ((safe-use-modules . use-modules)))

(define-syntax-rule (safe-use-modules modules ...)
  (begin
    (format #t "loading modules ~a... " '(modules ...))
    (use-modules modules ...)
    (format #t "done!\n")))

You'd need to replace the the messages with some thread
synchronization mechanism, to make sure that if one thread calls
"use-modules", all the others that would try to do that at that time
would have to wait.

I don't know if that would resolve all the problems concerning the
issue, because I don't know the guts of the module system. Perhaps
some other situations would need to be considered, in particular error
handling (to make sure, that an error in one module doesn't cause
other threads to wait forever).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]