caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nathaniel Gray" <n8gray@gmail.com>
To: skaller <skaller@users.sourceforge.net>
Cc: "Jacques Garrigue" <garrigue@math.nagoya-u.ac.jp>,
	caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: Select on channels (again)
Date: Wed, 23 Aug 2006 12:31:00 -0700	[thread overview]
Message-ID: <aee06c9e0608231231w26e34f8cs6e44e55ed2c236ab@mail.gmail.com> (raw)
In-Reply-To: <1156314944.7834.46.camel@rosella.wigram>

On 8/22/06, skaller <skaller@users.sourceforge.net> wrote:
> On Tue, 2006-08-22 at 22:16 -0700, Nathaniel Gray wrote:
>
> > You're right -- *truly* non-blocking Marshal.from_channel requires
> > more than select on channels, but it's often good enough to know if
> > there's any data in the channel at all.  It's often acceptable to
> > block long enough for the *rest* of a partial message to arrive but
> > unacceptable to block indefinitely waiting for a new message to
> > arrive.
> >
> > In any case, Marshal.from_channel isn't the only reason one might want
> > select on channels.  Is this something the dev team would be willing
> > to accept as a patch?  It's a pretty trivial thing to implement.
>
> The problem would be the semantics you indicate above.
> You're going to get non-blocking behaviour when the
> channels are quiet, but once there is some data,
> you get blocking.

I don't follow you.  Are you talking about input or output channels?
Can you give an example?

I suppose that on output channels you might not want to try to write
to the buffer if the fd is blocked, but you can always use plain old
Unix.select to check for that condition.

> It sounds hard to reason about the
> properties of a system with these semantics:
> you can already get the fd of a channel and select
> on it, and have a similar problem (fd is quiet,
> the buffer has data).

The semantics would be the same as the normal select.  If an
in_channel is ready it means at least one byte can be read without
blocking.  If an out_channel is ready then at least one byte can be
written without blocking.

> An alternative may be a pair of functions:
>
>         bytes_of_in_channel: in_channel -> int
>         bytes_of_out_channel: out_channel -> int
>
> which tell how much data remains in the buffers,
> you could use that in conjunction with Unix.select.

That would be sufficient, but it would end up being a bit deceptive --
both sizes would be limited by the buffer sizes involved.

There are lots of ways to skin this particular cat.  I chose
channel_select because it reveals very little about implementation
details like buffer sizes, which seems in keeping with the rest of the
channel API.  Another option would be {in,out}_channel_ready, upon
which one could easily build channel_select.

Cheers,
-n8

-- 
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->


  reply	other threads:[~2006-08-23 19:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-15  0:46 Nathaniel Gray
2006-08-21 22:47 ` Nathaniel Gray
2006-08-22  0:42   ` [Caml-list] " Jonathan Roewen
2006-08-22  6:27     ` Nathaniel Gray
2006-08-22  6:41       ` Jonathan Roewen
2006-08-22  8:15         ` skaller
2006-08-22 21:15           ` Mike Lin
2006-08-23  5:12         ` Nathaniel Gray
2006-08-22  8:10       ` Olivier Andrieu
2006-08-23  5:27         ` Nathaniel Gray
2006-08-22  8:21       ` Jacques Garrigue
2006-08-23  5:16         ` Nathaniel Gray
2006-08-23  6:35           ` skaller
2006-08-23 19:31             ` Nathaniel Gray [this message]
2006-08-24  5:37               ` skaller
2006-08-24 19:06                 ` Nathaniel Gray
2006-08-25  1:55                   ` skaller
2006-08-25 22:19                     ` Nathaniel Gray
2006-08-23  8:29 Christoph Bauer
2006-08-23 17:35 ` Robert Roessler
2006-08-24  8:18 ` Robert Roessler

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=aee06c9e0608231231w26e34f8cs6e44e55ed2c236ab@mail.gmail.com \
    --to=n8gray@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    --cc=skaller@users.sourceforge.net \
    /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;
as well as URLs for NNTP newsgroup(s).