From: Bardur Arantsson <spam@scientician.net>
To: caml-list@inria.fr
Subject: Re: Help interfacing with C
Date: Thu, 17 Aug 2006 07:56:28 +0200 [thread overview]
Message-ID: <ec10ed$6du$1@sea.gmane.org> (raw)
In-Reply-To: <aee06c9e0608161234l5c9e69a3he67c9caf903e69c7@mail.gmail.com>
Nathaniel Gray wrote:
> Hi folks,
[--snip--]
> have select work on (file_descr * 'a) pairs instead of plain file
> descriptors.
It's much easier than that; just define a conversion in OCaml:
external file_descr_to_int : file_descr -> int = "%identity";
external int_to_file_descr : int -> file_descr = "%identity";
and use
let my_select r w e t =
let r' = List.map file_descr_to_int r
and w' = List.map file_descr_to_int w
and e' = List.map file_descr_to_int e
in
Unix.select r' w' e' t;;
You seem to be doing the mapping of the result values, but that is just
a question of mapping int_to_file_descr over the result lists.
Of course this may be rather slower than your version, but Unix.select
is very very slow anyway since it's allocating at least one list for
every single call... and iterating through all(?) the file descriptors
in the input FD_SETs as well.
[Shameless plug below: If you want better performance, you might want
to try
http://www.imada.sdu.dk/~bardur/personal/45-programs/ocaml-events/ocaml-events-0.1.0.tar.bz2
I must warn you, though, that there are no timers or signal handling: It
turned out I didn't them for my particular application, so I haven't
bothered adding support. The actual FD polling/selection has worked very
reliably for me.]
--
Bardur Arantsson
<bardurREMOVE@THISscientician.net>
The truth is out there, but lies are in your head.
Terry Pratchett, 'Hogfather'
next prev parent reply other threads:[~2006-08-18 2:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-16 19:34 Nathaniel Gray
2006-08-17 3:49 ` [Caml-list] " malc
2006-08-18 21:00 ` Nathaniel Gray
2006-08-17 5:56 ` Bardur Arantsson [this message]
2006-08-18 7:10 ` [Caml-list] " Olivier Andrieu
2006-08-18 15:50 ` Bardur Arantsson
2006-08-18 21:33 ` [Caml-list] " Nathaniel Gray
2006-08-18 22:24 ` Bardur Arantsson
2006-08-19 0:33 ` [Caml-list] " Nathaniel Gray
2006-08-19 6:03 ` Bardur Arantsson
2006-08-21 22:45 ` [Caml-list] " Nathaniel Gray
2006-08-19 8:30 ` Olivier Andrieu
2006-08-21 22:35 ` Nathaniel Gray
2006-08-19 9:03 ` Richard Jones
2006-08-19 9:41 ` skaller
2006-08-18 8:46 ` [Caml-list] " Damien Doligez
2006-08-18 20:09 ` Nathaniel Gray
2006-08-23 23:36 ` Nathaniel Gray
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='ec10ed$6du$1@sea.gmane.org' \
--to=spam@scientician.net \
--cc=caml-list@inria.fr \
/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