[MLton] filedes = int (was: Stack size?)
Wesley W. Terpstra
Mon, 11 Jul 2005 22:02:40 +0200
On Fri, Jul 08, 2005 at 05:52:50PM +0200, Wesley W. Terpstra wrote:
> On Fri, Jul 08, 2005 at 11:06:59AM -0400, Matthew Fluet wrote:
> > > Or should I simply lobby to have epoll and kqueue exposed in yet another
> > > MLton.YourSyscallHere?
> > That is a possibility, but I agree that MLton.* is getting a bit ad hoc.
> > A better solution might be to introduce a MLton.Reps or MLton.FFI.Reps
> > structure, along the lines of:
> > val packSock : int -> ('af, 'sock_type) Socket.sock;
> > val unpackSock : ('af, 'sock_type) Socket.sock -> int;
> Anyways, I certainly agree that something in MLton to unpack the basis types
> for use in the FFI is the right thing to do in the long term.
Ok, I now have a working epoll interface. Hooray! =)
Use of MLtonPointer eliminated the need for C-glue code.
To get things working, I hacked MLton by adding a getFD to Socket.
However, I now have a better idea than my previous suggestion:
- datatype sock = S of Prim.sock
+ type sock = Prim.sock
After all, this is going to be protected by the signature anyways.
The only place where this will make a difference is the FFI (?).
... which is exactly where we want it to be an 'int'.
Also, the same goes for posix file descriptors:
- datatype file_desc = FD of int
+ type file_desc = int
I understand that _inside the basis_ there is a loss of abstraction, but in
this case I think the benefit (FFI friendly descriptors) outweighs the small
chance of confusion about the nature of that particular integer.
Another upside: no need for yet another MLton.X interface.
PS, there is a bug in OS.Process.sleep: it sleeps too short.
Once the sleep time drops below 1s, it returns immediately.
I admit that the basis specification does not say you must guarantee to
sleep at least as long as the parameter, but that is standard UNIX...
You might want to use usleep, though I don't know about windows.
Wesley W. Terpstra