1 /*-------------------------------------------------------------------------
4 * Portable delay handling.
7 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
9 * $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.7 2006/03/05 15:59:10 momjian Exp $
11 *-------------------------------------------------------------------------
19 * pg_usleep --- delay the specified number of microseconds.
21 * NOTE: although the delay is specified in microseconds, the effective
22 * resolution is only 1/HZ, or 10 milliseconds, on most Unixen. Expect
23 * the requested delay to be rounded up to the next resolution boundary.
25 * On machines where "long" is 32 bits, the maximum delay is ~2000 seconds.
31 pg_usleep(long microsec)
38 delay.tv_sec = microsec / 1000000L;
39 delay.tv_usec = microsec % 1000000L;
40 (void) select(0, NULL, NULL, NULL, &delay);
42 SleepEx((microsec < 500 ? 1 : (microsec + 500) / 1000), FALSE);