[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [guile-2.2] threads
From: |
Han-Wen Nienhuys |
Subject: |
Re: [guile-2.2] threads |
Date: |
Thu, 6 Apr 2017 00:29:59 +0200 |
On Wed, Apr 5, 2017 at 8:17 PM, David Kastrup <address@hidden> wrote:
> Han-Wen Nienhuys <address@hidden> writes:
>
>> LilyPond has no thread-safety anywhere. It would be actively harmful
>> if anybody ever tried to run something on a different thread.
>
> The Boehm GC garbage collector defaults to running in its own thread.
> It is set to "Java" collection semantics which separates marking and
> finalization phases.
It's not about the garbage collection. It's about shared state. Consider
SCM l ; // global variable
void add(SCM val) {
SCM new_head = scm_cons(val, l);
l = new_head;
}
if you have two threads doing this without synchronization, there is
no guarantee on what you'll end up with. Most likely, one of the
updates would get lost, but I have seen thread-unsafe use of STL
hashmaps result in cyclical lists, for example, and I wouldn't be
surprised if that could happen here too.
Or imagine that two threads try to lookup a font by calling into
fontconfig at the same time. LilyPond has one global font-config
instance (see lily/font-config.cc), and fontconfig is not thread-safe.
>> If anything, you should find a way to forbid importing the threads
>> package.
>
> Not sure whether it isn't needed anyhow.
--
Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwe