From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: Potluck - thread safe event loop with await semantics Date: Tue, 23 Feb 2016 03:25:52 -0300 Message-ID: <20160223032552.620074ed@capac> References: <20160216214512.42e6fd39@bother.homenet> <878u2dosxu.fsf@gnu.org> <20160222174056.2091d806@dell.homenet> <20160222172804.6d40b0c3@capac> <20160223003121.4ae217f1@dell.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/jSbJSdmQbHd+X81wIXoYvPH"; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1456208797 20113 80.91.229.3 (23 Feb 2016 06:26:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Feb 2016 06:26:37 +0000 (UTC) Cc: guile-user@gnu.org To: Chris Vine Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Feb 23 07:26:28 2016 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 1aY6QW-0006pi-4M for guile-user@m.gmane.org; Tue, 23 Feb 2016 07:26:28 +0100 Original-Received: from localhost ([::1]:54293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY6QV-0001nS-CP for guile-user@m.gmane.org; Tue, 23 Feb 2016 01:26:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY6QL-0001nB-RH for guile-user@gnu.org; Tue, 23 Feb 2016 01:26:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aY6QI-0007rQ-JO for guile-user@gnu.org; Tue, 23 Feb 2016 01:26:17 -0500 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:48881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY6QI-0007qU-AH for guile-user@gnu.org; Tue, 23 Feb 2016 01:26:14 -0500 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id 06FD1A04C236; Tue, 23 Feb 2016 07:26:13 +0100 (CET) Original-Received: from maximusconfessor.all2all.org ([192.168.0.1]) by localhost (maximusconfessor.all2all.org [192.168.0.2]) (amavisd-new, port 10024) with ESMTP id OGo2otINlZtb; Tue, 23 Feb 2016 07:26:07 +0100 (CET) Original-Received: from capac (unknown [179.210.37.116]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id 0C626A04C233; Tue, 23 Feb 2016 07:26:06 +0100 (CET) In-Reply-To: <20160223003121.4ae217f1@dell.homenet> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 79.99.200.102 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:12432 Archived-At: --Sig_/jSbJSdmQbHd+X81wIXoYvPH Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Chris, > When I tested guile-gnome a few years ago I could reliably get > g-idle-add to crash when calling it from a worker thread. If that is > no longer the case I am pleased to hear it. However, the little test > program at the end[1], which prints to the screen every 1/10th of a > second, will also segfault for me Ah. no, it segfaults here too, but as you know, this example makes a new and a new (g-idle-source-new), sets and attach the source ... every call: I= guess the problem is none are freed/released, or at least not 'properly' ? I don't know. Would an 'exact same' C program using pthread work fine? Probably, = but it would be nice to confirm. In anycase, I will need Andy's help to debug and= patch this. Did you talked to him back then? Note that this works fine [1]. I understand it is not 'the same thing' but = just wanted to test this and it does not fail, to be confirmed but I did leave i= t run for a while. So, I don't think it is because Guile-gnome 'turns glib thread un= safe', but because something is missing in our implementation [ that make these gobject closures and sources properly freed? ]. > As it happens, I am familiar with GTK+/glib thread safety. I have > written a library which depends on it. g_idle_add(), and the other > glib main loop functions, are and always have been completely thread > safe.=20 Ok, I see: I thought you wanted/ment to use threads to interact with gdk/gt= k, I missunderstood, sorry, and I see you know more then I here, good! =20 > As it happens, g-thread-init isn't wrapped, but there is no need > to call g_thread_init() anyway since glib >=3D 2.32.=20 > ... Ok > On a separate matter, can you fix g-io-add-watch if that has not yet > happened? If you try to call it, compilation errors with: >=20 > ERROR: In procedure module-lookup: Unbound variable: I don't know much [almost nothing] about that part, but it fails here too. = I'll see what I can do but don't hold your breath, and friends use spe= cial wrappers, so the help of Andy would be precious here too ... I wish you'd know more about our implementation and be more efficient as we= ll :)=20 > It is off topic, but what guile-gnome really needs is a wrapper for > gobject-introspection. No doubt: there is sbank [2], but I could not find the time to even look at= it so far... There was also guile-gir [it was on gitorious, I have a local copy, = 6y old] Cheers, David [1] #! /bin/sh # -*- mode: scheme; coding: utf-8 -*- exec guile -e main -s "$0" "$@" !# (use-modules (gnome-2) (gnome glib)) (define (main args) (let ((loop (g-main-loop-new #f #f))) (call-with-new-thread (lambda () (g-timeout-add 100 (lambda () (display "running ") #t)))) ;; yes, keep the timeout (display "Starting main loop\n") (g-main-loop-run loop))) [2] http://rotty.xx.vu/software/sbank/ --Sig_/jSbJSdmQbHd+X81wIXoYvPH Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWy/twAAoJEPN0/ZOjBXrX47sIAJLIBnI9j9EOtTejYboT148L hnACwk0bwds4Ojf+tQCO17nYtUdot+AXqzlOejp15zbOQnmQ+ZwBm9FD+X5jdru7 9qR0WBob9al+vfqd4R4Lpc1diGrNAQloKWJX2qUalFvPR5PZPIQ7u+cOJ4CfbYoL RKlaZBxKiTXPTSTKXgynwhiDbwra5FhEtcvUMhzQLAhvy4IQ0k4yhUbllmufCShP 6qTGxmLMkvnZ/vowwCDdCChsSJTAu/IStPbrJomYoLoayIHwOSrhE+1yjXHNc1fV u0yAygc4A6x32JRWEWWe93snOSO5J9/it8c1+cGcasDC/4c2LhmkWkNz/65oCl4= =1N/K -----END PGP SIGNATURE----- --Sig_/jSbJSdmQbHd+X81wIXoYvPH--