Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -99,10 +99,15 @@ /** * \return The current thread or nil if we are in the main thread */ + (OFThread*)currentThread; +/** + * Suspends execution of the current thread for N milliseconds. + */ ++ (void)sleepForNMilliseconds: (unsigned int)msecs; + /** * Terminates the current thread, letting it return nil. */ + (void)terminate; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -8,10 +8,16 @@ * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #include "config.h" + +#ifndef _WIN32 +# include +#else +# include +#endif #import "OFThread.h" #import "OFList.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" @@ -82,10 +88,19 @@ + (OFThread*)currentThread { return of_tlskey_get(thread_self); } + ++ (void)sleepForNMilliseconds: (unsigned int)msecs; +{ +#ifndef _WIN32 + usleep(msecs * 1000); +#else + Sleep(msecs); +#endif +} + (void)terminate { [self terminateWithObject: nil]; }