From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Panicz Maciej Godek Newsgroups: gmane.lisp.guile.user Subject: Re: libguile thread safety Date: Sun, 5 Jan 2014 14:15:42 +0100 Message-ID: References: <20140103233407.36382e5f@bother.homenet> <8738l41p8r.fsf@netris.org> <20140104124459.6c604ae1@bother.homenet> <87y52vzgfc.fsf@netris.org> <20140104210118.3564073f@bother.homenet> <20140104233120.77b0edaa@bother.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1388927753 5011 80.91.229.3 (5 Jan 2014 13:15:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 5 Jan 2014 13:15:53 +0000 (UTC) Cc: "guile-user@gnu.org" To: Chris Vine Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jan 05 14:16:00 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VznYd-0001me-7b for guile-user@m.gmane.org; Sun, 05 Jan 2014 14:15:59 +0100 Original-Received: from localhost ([::1]:57888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VznYc-0002Yi-Om for guile-user@m.gmane.org; Sun, 05 Jan 2014 08:15:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VznYP-0002UD-5f for guile-user@gnu.org; Sun, 05 Jan 2014 08:15:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VznYN-0006Fa-V8 for guile-user@gnu.org; Sun, 05 Jan 2014 08:15:45 -0500 Original-Received: from mail-we0-x22f.google.com ([2a00:1450:400c:c03::22f]:61487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VznYN-0006Ee-OW for guile-user@gnu.org; Sun, 05 Jan 2014 08:15:43 -0500 Original-Received: by mail-we0-f175.google.com with SMTP id t60so14761551wes.20 for ; Sun, 05 Jan 2014 05:15:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ZQtgOL+2px1BKDt8r3Zp0pJCzvTZPLdjaEsQ5LZRQeQ=; b=c5XW458WLi1hbLStTzlhP0C3E4KNAKNYcI32aabhfFWfPRgIsCgXFQXejv3bTw4Q3X U31pGrgPYj5xB4LcrwmKdcjJMIWI3Zq+8RMm4J2b3qa+H8E7DpNNyasqN+VX5HyWyh7W WswtOGrk93XCmU0GevtDvZ875HT1sYN3Puby1bf9GUXZ1H7N+ydNgr39+SQDJZ0y7H/m M0sm5Au24BwkhJDLmcBtEi8F+Tugay0w0G+2kQwHD82+pXkHpazhGx5EEunllIgyRG5R d+2w1GbX+rRANuGndE6ZXN3JiROGJ4ufwxKApaSOlYOgcMWLs6tXf6sPLCIXqHvUthJJ fHcg== X-Received: by 10.180.21.244 with SMTP id y20mr8793643wie.37.1388927742472; Sun, 05 Jan 2014 05:15:42 -0800 (PST) Original-Received: by 10.194.178.134 with HTTP; Sun, 5 Jan 2014 05:15:42 -0800 (PST) In-Reply-To: <20140104233120.77b0edaa@bother.homenet> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22f X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10981 Archived-At: 2014/1/5 Chris Vine : > 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).