Computation @hReady hdl@ indicates whether at least
one item is available for input from handle {\em hdl}.
-@hWaitForInput@ is the generalisation, wait for \tr{n} seconds
+@hWaitForInput@ is the generalisation, wait for \tr{n} milliseconds
before deciding whether the Handle has run dry or not.
\begin{code}
hReady h = hWaitForInput h 0
--hWaitForInput :: Handle -> Int -> IO Bool
-hWaitForInput handle nsecs = do
+hWaitForInput handle msecs = do
hdl <- wantReadableHandle handle
- rc <- _ccall_ inputReady (filePtr hdl) nsecs
+ rc <- _ccall_ inputReady (filePtr hdl) msecs
writeHandle handle (markHandle hdl)
case rc of
0 -> return False
#endif
StgInt
-inputReady(fp, nsecs)
+inputReady(fp, msecs)
StgForeignObj fp;
-StgInt nsecs;
+StgInt msecs;
{
int flags, c, fd, maxfd, ready;
fd_set rfd;
FD_SET(fd, &rfd);
/* select() will consider the descriptor set in the range of 0 to (maxfd-1) */
maxfd = fd + 1;
- tv.tv_usec = 0;
- tv.tv_sec = nsecs;
+ tv.tv_sec = msecs / 1000;
+ tv.tv_usec = msecs % 1000;
while ((ready = select(maxfd, &rfd, NULL, NULL, &tv)) < 0 ) {
if (errno != EINTR ) {
cvtErrno();