English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Select on channels (again)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-08-25 (01:56)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Re: Select on channels (again)
On Thu, 2006-08-24 at 12:06 -0700, Nathaniel Gray wrote:
> On 8/23/06, skaller <skaller@users.sourceforge.net> wrote:
> >
> > IF you had some known semantics such as that
> > messages were of bounded length and transmitted
> > in bounded time .. select would be useful, since
> > blocking operations would block only for bounded time,
> > in which case they're not blocking at all.
> That's exactly what I'm talking about.  There are plenty of cases
> where such assumptions are justified, including IPC on a single
> machine or communication on a small trusted network.  Select on
> channels is no more or less useful than regular select, other than the
> fact that it makes it possible to use OCaml functions that only
> operate on channels.

This is true, and in C it is the same:

	sscanf(... )

are both going to block, possibly for a bounded time
if they're only called when you know the underlying
fd has, at least temporarily, enough throughput to allow
the formatting algorithms to terminate.

The thing is, you can already do this, guaranteed!
It is rather heavy though: you make two pthreads
and read one fd in each, then send the
results down a single Event channel: the user code
can then read the parsed objects in sequence,
blocking until the first is available, then blocking
until the second is available.

The point is that although this is heavy, it is guaranteed
to work, so using Event module with pthreads is actually
easier to reason about.

If you would like to do this without the cost of spawning
pthreads .. then you need to use Felix, not Ocaml :)

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net