Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Kaspar Rohrer <krohrer@student.ethz.ch>
To: Julien Moutinho <julien.moutinho@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Native multithreaded LablGTK2?
Date: Mon, 30 Jul 2007 15:22:04 +0200	[thread overview]
Message-ID: <498E26F4-E414-48A1-ADDE-8A6E03486E82@student.ethz.ch> (raw)
In-Reply-To: <20070730115725.GB28423@jiyu.gnu>

On 30.07.2007, at 13:57, Julien Moutinho wrote:

> Oki douki, it's just that I did not undertand why you use std(in|out)
> to communicate between threads... But you use them because you want
> a buffering machinery and you have only looked at Pervasives, right?
No, the problem is of a different nature: I want to capture standard  
output and display it in a (log) window in my Gtk application. I'm  
aware that I could just use custom output functions, but the main  
problem here is that I've embedded a Scheme interpreter (Ocs,  
actually: http://will.iki.fi/software/ocs/) which writes to stdout by  
default. Now, of course I could adapt Ocs to suit my needs. But I  
have no intention to do so at the moment (although it would be  
relatively straight forward by extending Ocs_port).

>> I'm piping stdout, because that's the only way I was able to redirect
>> stdout to a gtk text widget (using a GIOchannel: GMain.Io.*). If  
>> anybody
>> has a better idea, I'd be glad to hear it. I was originally  
>> thinking of  an
>> out_channel that writes to a buffer instead of a file, but the Ocaml
>> standard library seems to be missing this functionality. Or is it?
> You have [Stream.t], [Buffer.t] and [GText.buffer] at your service.
>
> HTH.
I actually already use a GText.buffer. In conjunction with piping and  
GMain.Io.add_watch, I am able to redirect standard output to the  
buffer and thus display it in a text widget. But this only works  
reliably if the application is multithreaded, because pipes have a  
fixed size buffer (something around 5000 bytes IIRC). Now, if the  
buffer was able to capture all output, this would work for a single  
thread also. Because writes to the buffer would never block, unlike  
writes to a pipe.
I might be wrong on all of the above though, as I am far from an  
expert on either Gtk or multithreading.

Anyway, thanks again. I really apreciate any help I can get.


  reply	other threads:[~2007-07-30 13:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-29 19:16 Kaspar Rohrer
2007-07-30  5:40 ` [Caml-list] " Julien Moutinho
2007-07-30  8:01   ` Kaspar Rohrer
2007-07-30 11:57     ` Julien Moutinho
2007-07-30 13:22       ` Kaspar Rohrer [this message]
2007-07-30  8:22   ` Kaspar Rohrer
2007-07-30 10:01     ` Julien Moutinho
2007-07-30 11:31       ` Kaspar Rohrer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=498E26F4-E414-48A1-ADDE-8A6E03486E82@student.ethz.ch \
    --to=krohrer@student.ethz.ch \
    --cc=caml-list@yquem.inria.fr \
    --cc=julien.moutinho@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox