Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -104,10 +104,16 @@ /** * Suspends execution of the current thread for N milliseconds. */ + (void)sleepForNMilliseconds: (unsigned int)msecs; +/** + * Yields a processor voluntarily and moves the thread at the end of the queue + * for its priority. + */ ++ (void)yield; + /** * Terminates the current thread, letting it return nil. */ + (void)terminate; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -11,10 +11,11 @@ #include "config.h" #ifndef _WIN32 # include +# include #else # include #endif #import "OFThread.h" @@ -97,10 +98,19 @@ usleep(msecs * 1000); #else Sleep(msecs); #endif } + ++ (void)yield +{ +#ifndef _WIN32 + sched_yield(); +#else + Sleep(0); +#endif +} + (void)terminate { [self terminateWithObject: nil]; }