## winix-io.api
#
# The threadkit version of the generic low-level I/O interface.
#
# Compare to:
#
#
src/lib/std/src/winix/winix-io--premicrothread.api# Compiled by:
#
src/lib/std/standard.libstipulate
package mop = mailop; # mailop is from
src/lib/src/lib/thread-kit/src/core-thread-kit/mailop.pkg package tim = time; # time is from
src/lib/std/time.pkg package wty = winix_types; # winix_types is from
src/lib/std/src/posix/winix-types.pkgherein
# This api is referenced in:
#
#
src/lib/src/lib/thread-kit/src/winix/winix.api #
src/lib/std/src/threadkit/posix/winix-io.pkg api Winix_Io {
#
eqtype Iod; # "Iod" == "I/O descriptor".
# An Iod is an abstract descriptor for an OS entity
# that supports I/O (e.g., file, tty device, socket, ...).
# (In practice on posix it is an Int encoding a host-OS fd.)
Iod_Kind = FILE # On posix defined by psx::stat::is_file
| DIRECTORY
# On posix defined by psx::stat::is_directory
| SYMLINK
# On posix defined by psx::stat::is_symlink
| CHAR_DEVICE
# On posix defined by psx::stat::is_char_dev
| BLOCK_DEVICE
# On posix defined by psx::stat::is_block_dev
| PIPE
# On posix defined by psx::stat::is_pipe
| SOCKET
# On posix defined by psx::stat::is_socket
| OTHER
# Future-proofing.
;
hash: Iod -> Unt; # Return a hash value for the I/O descriptor.
compare: (Iod, Iod) -> Order; # Compare two I/O descriptors
iod_to_iodkind: Iod -> wty::Iod_Kind; # Classify iod as FILE/DIR/SYMLINK/TTY/PIPE/SOCKET/DEVICE
# Existing code uses this only to check for TTY, mostly to select line-buffering vs block buffering.
Ioplea = { io_descriptor: Iod,
readable: Bool,
writable: Bool,
oobdable: Bool # Out-Of-Band-Data available on socket or PTY.
};
#
# Public representation of a polling operation on
# an I/O descriptor.
Ioplea_Result = Ioplea; # A synonym to clarify declarations.
exception BAD_WAIT_REQUEST;
# The next two provide Mythryl-world access to the
# wait-for-some-file-descriptor-to-wake-up functionality
# which at the C level is provided on BSD by select()
# and on SysV by poll():
wait_for_io_opportunity
:
( List( Ioplea ), # Only one-element lists supported at present.
Null_Or( Float ) # Timeout: NULL means wait indefinitely; (THE 0.0) means do not block.
)
->
List( Ioplea_Result );
wait_for_io_opportunity_mailop
:
List( Ioplea ) # Only one-element lists supported at present.
->
mop::Mailop( List( Ioplea_Result ) );
}; # Winix_Io__Premicrothread
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.