Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -112,13 +112,24 @@ * \return The current thread or nil if we are in the main thread */ + (OFThread*)currentThread; /** - * Suspends execution of the current thread for N milliseconds. + * Suspends execution of the current thread for the specified time interval. + * + * \param sec The number of seconds to sleep + */ ++ (void)sleepForTimeInterval: (int64_t)sec; + +/** + * Suspends execution of the current thread for the specified time interval. + * + * \param sec The number of seconds to sleep + * \param usec The number of microseconds to sleep */ -+ (void)sleepForNMilliseconds: (unsigned int)msecs; ++ (void)sleepForTimeInterval: (int64_t)sec + microseconds: (uint32_t)usec; /** * Suspends execution of the current thread until the specified date. */ + (void)sleepUntilDate: (OFDate*)date; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -94,17 +94,33 @@ + (OFThread*)currentThread { return of_tlskey_get(thread_self); } -+ (void)sleepForNMilliseconds: (unsigned int)msecs; ++ (void)sleepForTimeInterval: (int64_t)sec +{ + if (sec < 0) + @throw [OFOutOfRangeException newWithClass: self]; + +#ifndef _WIN32 + sleep(sec); +#else + Sleep(sec * 1000); +#endif +} + ++ (void)sleepForTimeInterval: (int64_t)sec + microseconds: (uint32_t)usec { + if (sec < 0) + @throw [OFOutOfRangeException newWithClass: self]; + #ifndef _WIN32 - sleep(msecs / 1000); - usleep((msecs % 1000) * 1000); + sleep(sec); + usleep(usec); #else - Sleep(msecs); + Sleep(sec * 1000 + usec / 1000); #endif } + (void)sleepUntilDate: (OFDate*)date {