guile-user
[Top][All Lists]
Advanced

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

Re: Potluck - thread safe event loop with await semantics


From: David Pirotte
Subject: Re: Potluck - thread safe event loop with await semantics
Date: Tue, 23 Feb 2016 03:25:52 -0300

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 
<gclosure>
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 it 
run for
a while.  So, I don't think it is because Guile-gnome 'turns glib thread 
unsafe',
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. 

Ok, I see: I thought you wanted/ment to use threads to interact with gdk/gtk, I
missunderstood, sorry, and I see you know more then I here, good!  

> As it happens, g-thread-init isn't wrapped, but there is no need
> to call g_thread_init() anyway since glib >= 2.32. 
> ...

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:
> 
>    ERROR: In procedure module-lookup: Unbound variable: <gio-channel>

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, <gio-channel> and friends use special
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 well 
:) 

> 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/

Attachment: pgpzAhOCsW8qj.pgp
Description: OpenPGP digital signature


reply via email to

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