static
| 180 | |
| 181 | // static |
| 182 | void 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 |
| 197 | const char* PlatformThread::GetName() { |
nothing calls this directly
no test coverage detected