OS.IO
structureThe OS.IO structure provides a general interface for polling IO devices. This has been modelled after the Unix SVR4 poll interface. A poll_desc, created from an IO descriptor, can be used to test for various polling conditions.
signature OS_IO
structure IO
: OS_IO
eqtype iodesc
val hash : iodesc -> word
val compare : (iodesc * iodesc) -> order
eqtype iodesc_kind
val kind : iodesc -> iodesc_kind
structure Kind : sig
val file : iodesc_kind
val dir : iodesc_kind
val symlink : iodesc_kind
val tty : iodesc_kind
val pipe : iodesc_kind
val socket : iodesc_kind
val device : iodesc_kind
end
type poll_desc
type poll_info
val pollDesc : iodesc -> poll_desc option
val pollToIODesc : poll_desc -> iodesc
exception Poll
val pollIn : poll_desc -> poll_desc
val pollOut : poll_desc -> poll_desc
val pollPri : poll_desc -> poll_desc
val poll : (poll_desc list * Time.time option) -> poll_info list
val isIn : poll_info -> bool
val isOut : poll_info -> bool
val isPri : poll_info -> bool
val infoToPollDesc : poll_info -> poll_desc
eqtype iodesc
Since iodesc values correspond to low-level, OS-specific objects, they are not typically created explicitly by the user, but are generated as a side-effect of the creation of a more high-level abstraction. For example, TextIO.openIn
creates an instream
value, from which the underlying PrimIO.reader
can be accessed. This latter value may contain the corresponding iodesc value.
If the underlying operating system is known, there will usually be mechanisms for converting between iodesc values and the type of value used by the operating system. For example, the functions Posix.FileSys.fdToIOD
and Posix.FileSys.iodToFD
provide this service for Posix implementations, translating between iodescs and open file descriptors.
hash iod
Implementation note:
hash must have the property that values produced are well distributed when taken modulo 2(n) for any n.
compare (iod, iod')
eqtype iodesc_kind
kind iod
structure Kind
val file
val dir
val symlink
val tty
val pipe
val socket
val device
true
will have this kind.
true
will have this kind.
Question:
Should there also be an
other
value to provide an escape hatch?
type poll_desc
type poll_info
poll
operation.
pollDesc iod
pollToIODesc pd
exception Poll
pollIn pd
pollOut pd
pollPri pd
poll (l, opt)
NONE
means wait indefinitely.
SOME(Time.zeroTime)
means do not block.
SOME(t)
mean timeout after time t
.
isIn info
isOut info
isPri info
true
if input (respectively, output, priority information) is present in info.
infoToPollDesc pi
Last Modified January 9, 1997
Copyright © 1996 AT&T