This is sleepDelay.c in view mode; [Download] [Up]
// ------------------------------------------------------------------------------------- // thread safe sleep function // ------------------------------------------------------------------------------------- // Permission is granted to freely redistribute this source code, and to use fragments // of this code in your own applications if you find them to be useful. This module, // along with the source code, come with no warranty of any kind, and the user assumes // all responsibility for its use. // ------------------------------------------------------------------------------------- #import <stdio.h> #import <ctype.h> #import <libc.h> #import <sys/types.h> #import <sys/stat.h> #import <sys/param.h> /* sleep for a number of seconds */ int sleepDelay(float sec) { u_long uSec; struct timeval to; fd_set list; /* set up for 'select()' function */ FD_ZERO(&list); FD_SET(1, &list); uSec = (u_long)(sec * 1000000.0); to.tv_sec = uSec / 1000000L; to.tv_usec = uSec % 1000000L; /* select call acts as delay */ return (select(1, &list, 0, 0, &to))? 0 : 1; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.