guile-devel
[Top][All Lists]
Advanced

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

Re: string-map arg order


From: Thomas Wawrzinek
Subject: Re: string-map arg order
Date: Wed, 5 Sep 2001 07:38:13 +0200 (MEST)

Hi!

address@hidden wrote:

 > I admit that the example is simplistic.  But, with multiple threads you
 > don't gain anything by using string-for-each either, except you were
 > inhibiting mutations to that string throughout the execution of
 > string-for-each by using some mutex.  This, however, does not work since
 > it would inhibit nesting these constructs.  The same argument holds for
 > the idea of using one mutex per string and having it locked during
 > string-map, string-fold or string-for-each, since you could not iterate
 > over the same string in a nested manner.

You mean you can't access the same mutex twice from the same thread?
POSIX threads have a property something like PTHREAD_MUTEX_RECURSIVE
which allows just that. However, it's not implemented on all platforms.

But note, that you can build your own mutex structure around a
pthread_mutex,  provide it with a counter and the thread id, and use these
for recursive uses from the same thread.

Of course, you have to protect every such own mutex structure from parallel
access by different threads, which requires an additional global (pthread)
mutex to do so.

Regards,

                        Thomas



reply via email to

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