18 #ifndef _GLIBCXX_ALGORITHM
40 t.tv_nsec = amount*1000;
44 t.tv_nsec = (amount-t.tv_sec*
MS)*
MS*1000;
53 arb_assert(t.tv_nsec>=0 && t.tv_nsec<=999999999);
56 struct timespec remain;
58 int res = nanosleep(&t, &remain);
65 #if defined(TRACE_SLEEP)
66 inline const char *timeUnitAbbr(
TimeUnit tu) {
68 case USEC:
return "usec";
78 int curr_wait, max_wait, inc;
81 void slowdown() { curr_wait =
std::min(max_wait, curr_wait+inc); }
84 : curr_wait(min_amount),
95 #if defined(TRACE_SLEEP)
96 fprintf(stderr,
"pid %i waits %i %s\n", getpid(), curr_wait, timeUnitAbbr(unit));
113 gettimeofday(&t2,
NULp);
114 return (t2.tv_sec - t1.tv_sec) *
SEC + (t2.tv_usec - t1.tv_usec);
126 : amount_usec(amount*tu)
135 #error arb_sleep.h included twice
136 #endif // ARB_SLEEP_H
ARB_inc_sleep(int min_amount, int max_amount, TimeUnit tu, int increment)
ARB_timeout(int amount, TimeUnit tu)
void ARB_sleep(int amount, TimeUnit tu)