MCPcopy Create free account
hub / github.com/apache/brpc / Sleep

Method Sleep

src/butil/threading/platform_thread_posix.cc:182–194  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

180
181// static
182void PlatformThread::Sleep(TimeDelta duration) {
183 struct timespec sleep_time, remaining;
184
185 // Break the duration into seconds and nanoseconds.
186 // NOTE: TimeDelta's microseconds are int64s while timespec's
187 // nanoseconds are longs, so this unpacking must prevent overflow.
188 sleep_time.tv_sec = duration.InSeconds();
189 duration -= TimeDelta::FromSeconds(sleep_time.tv_sec);
190 sleep_time.tv_nsec = duration.InMicroseconds() * 1000; // nanoseconds
191
192 while (nanosleep(&sleep_time, &remaining) == -1 && errno == EINTR)
193 sleep_time = remaining;
194}
195
196// static
197const char* PlatformThread::GetName() {

Callers

nothing calls this directly

Calls 2

InSecondsMethod · 0.80
InMicrosecondsMethod · 0.80

Tested by

no test coverage detected