[Haskell-cafe] carry "state" around ....

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sat Jul 19 09:28:38 EDT 2008

On Sat, 2008-07-19 at 01:40 -0500, Galchin, Vasili wrote:
> hello,
>     Following is more of a criticism of Linux implementation of the
> Posix real-time extension of asynchronous I/O.... if not interesting
> please skip. The central data structure for Posix AIO is an aiocb. In
> any case, the Linux implementors added to the aiocb:


> My viewpoint is that the above "Internal members" must be "carried"
> around in a Haskell program. Am I correct?? If I am correct, then the
> Linux implementation of Posix AIO is not portable to say Solaris? In
> hindsight, if I am correct, it seems that the Linux implementation of
> AIO should use the ordered pair (pid, fd) to reference the "internal"
> members and leave the "aiocb" "clean"?

Although it is different between platforms it is still portable. When
you allocate memory in C for the aiocb struct you would use
sizeof(aiocb). That's portable even if the size is different on Linux vs
Solaris. Then members are only accessed by name which is again portable.

Your problem perhaps is that you're trying to convert an aiocb into a
pure haskell version and convert it back and expect to retain all the
information. I think that is a mistake. Don't pass the aiocb's by value,
pass them by reference. Use a ForeignPtr and just access the members you
need whenever you need them.


More information about the Haskell-Cafe mailing list