Version française
Home     About     Download     Resources     Contact us    
Browse thread
LablGTK app maxes out CPU
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eric Cooper <ecc@c...>
Subject: Re: [Caml-list] LablGTK app maxes out CPU
On Tue, Jul 04, 2006 at 02:00:46PM -0600, Matt Gushee wrote:
> Eric Cooper wrote:
> >Try making the fd nonblocking before you create the glib channel:
> >    Unix.set_nonblock msg_fd;
> 
> That's how it was originally. But if you look again at my code, you can 
> see that the version with Unix.O_NONBLOCK is commented out. That's 
> because on one of my machines (the one with a newer version of GTK and 
> LablGTK, I believe), I got exceptions every time the program tried to 
> read the input.

Right, me too.  I use code like this to read from the channel inside
the watcher:

let try_read chan ~buf ~pos ~len =
  try Some (Glib.Io.read chan ~buf ~pos ~len)
  with Glib.GError "g_io_channel_read: G_IO_ERROR_AGAIN" -> None

-- 
Eric Cooper             e c c @ c m u . e d u