1 /*-------------------------------------------------------------------------
4 * Portable delay handling.
7 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
11 *-------------------------------------------------------------------------
19 * In a Windows backend, we don't use this implementation, but rather
20 * the signal-aware version in src/backend/port/win32/signal.c.
22 #if defined(FRONTEND) || !defined(WIN32)
25 * pg_usleep --- delay the specified number of microseconds.
27 * NOTE: although the delay is specified in microseconds, the effective
28 * resolution is only 1/HZ, or 10 milliseconds, on most Unixen. Expect
29 * the requested delay to be rounded up to the next resolution boundary.
31 * On machines where "long" is 32 bits, the maximum delay is ~2000 seconds.
34 pg_usleep(long microsec
)
41 delay
.tv_sec
= microsec
/ 1000000L;
42 delay
.tv_usec
= microsec
% 1000000L;
43 (void) select(0, NULL
, NULL
, NULL
, &delay
);
45 SleepEx((microsec
< 500 ? 1 : (microsec
+ 500) / 1000), FALSE
);
50 #endif /* defined(FRONTEND) || !defined(WIN32) */