///////////////////////////////////////////////////////
| 36 | { |
| 37 | //////////////////////////////////////////////////////////// |
| 38 | void sleepImpl(Time time) |
| 39 | { |
| 40 | const std::int64_t usecs = time.asMicroseconds(); |
| 41 | |
| 42 | // Construct the time to wait |
| 43 | timespec ti{}; |
| 44 | ti.tv_sec = static_cast<time_t>(usecs / 1'000'000); |
| 45 | ti.tv_nsec = static_cast<long>((usecs % 1'000'000) * 1'000); |
| 46 | |
| 47 | // Wait... |
| 48 | // If nanosleep returns -1, we check errno. If it is EINTR |
| 49 | // nanosleep was interrupted and has set ti to the remaining |
| 50 | // duration. We continue sleeping until the complete duration |
| 51 | // has passed. We stop sleeping if it was due to an error. |
| 52 | while ((nanosleep(&ti, &ti) == -1) && (errno == EINTR)) |
| 53 | { |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | } // namespace sf::priv |