PostgreSQL Source Code  git master
pgsleep.c File Reference
#include "c.h"
#include <time.h>
Include dependency graph for pgsleep.c:

Go to the source code of this file.

Functions

void pg_usleep (long microsec)
 

Function Documentation

◆ pg_usleep()

void pg_usleep ( long  microsec)

Definition at line 41 of file pgsleep.c.

42 {
43  if (microsec > 0)
44  {
45 #ifndef WIN32
46  struct timespec delay;
47 
48  delay.tv_sec = microsec / 1000000L;
49  delay.tv_nsec = (microsec % 1000000L) * 1000;
50  (void) nanosleep(&delay, NULL);
51 #else
52  SleepEx((microsec < 500 ? 1 : (microsec + 500) / 1000), FALSE);
53 #endif
54  }
55 }