To: nicolas.george at ens.fr Cc: jehenrik at yahoo.com, lablgtk at kaba.or.jp Subject: Re: lablgtk bugs In-Reply-To: <20010503090407.A18020 at clipper.ens.fr> References: <001c01c0d390$742c8540$4d4106d1 at mit.edu> <20010503090407.A18020@clipper.ens.fr> Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-Id: <20010504082917Y.garrigue at kurims.kyoto-u.ac.jp> Date: Fri, 04 May 2001 08:29:17 +0900 From: Jacques Garrigue Lines: 56 From: Nicolas GEORGE > Le quartidi 14 flor=E9al, an CCIX, Jeff Henrikson a =E9crit=A0: > > 2) Is there a way to repaint a window in a multithreaded app from a > > non-drawing thread? It seems that most of the examples just call th= eir > > own paint handlers directly. > = > Yes, it is quite common. > = > > This is bad when you have multiple theads > > because to get your drawing right it's best to have only one thread > > drawing. > = > Right. More=A0: Gdk doesn't allow to use graphics primitives in more t= han > one thread. Note that if you are using bytecode version without system= > threads, this is not a problem=A0; but you can not rely on that. Well, I studied the threading code in ocaml a while before reaching the conclusion that this is OK, even with native code using system threads. That is, the system makes sure that all calls to gdk are single-threaded. You don't have to bother at all about threading issues ---as long as you don't have independent C threads using GTK in your application, a problem I had when linking a lablgtk program with Mozilla. Why is it so? Basically, the caml runtime uses a big lock, to make sure that only one thread is running caml code at any time (mainly for GC reasons I believe). This lock is only released when calling some specific C functions, to allow them to block. But calls to the GDK do not release the lock, so you can only have one single call to the GDK occuring at a time. You may switch to another concurrent C thread at that time, but you will not be able to go back into caml code to initiate another GDK call. Also, I took some care of making lablgtk itself re-entrant. I hope this is correct. Actually we had some multi-thread GDK application running, and didn't bother about from where to call functions at all. Best regards, Jacques ------------------------------------------------------------------------= --- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac= .jp JG