@@ -17,10 +17,12 @@ #import "OFObject.h" #import "OFList.h" #import "threading.h" +@class OFDate; + /** * \brief A class for Thread Local Storage keys. */ @interface OFTLSKey: OFObject { @@ -33,17 +35,17 @@ } /** * \return A new autoreleased Thread Local Storage key */ -+ tlsKey; ++ TLSKey; /** * \param destructor A destructor that is called when the thread is terminated * \return A new autoreleased Thread Local Storage key */ -+ tlsKeyWithDestructor: (void(*)(id))destructor; ++ TLSKeyWithDestructor: (void(*)(id))destructor; + (void)callAllDestructors; /** * \return An initialized Thread Local Storage key @@ -74,13 +76,18 @@ OF_THREAD_WAITING_FOR_JOIN } running; id retval; } +/** + * \return A new, autoreleased thread + */ ++ thread; + /** * \param obj An object that is passed to the main method as a copy or nil - * \return A new autoreleased thread + * \return A new, autoreleased thread */ + threadWithObject: (id)obj; /** * Sets the Thread Local Storage for the specified key. @@ -89,14 +96,13 @@ * released. You can specify nil as object if you want the old object to be * released and don't want any new object for the TLS key. * * \param key The Thread Local Storage key * \param obj The object the Thread Local Storage key will be set to - * \return The old object, autoreleased */ -+ (id)setObject: (id)obj - forTLSKey: (OFTLSKey*)key; ++ (void)setObject: (id)obj + forTLSKey: (OFTLSKey*)key; /** * Returns the object for the specified Thread Local Storage key. * * The returned object is not retained and autoreleased for performance @@ -110,13 +116,29 @@ * \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)sleepForTimeInterval: (int64_t)sec + microseconds: (uint32_t)usec; + +/** + * Suspends execution of the current thread until the specified date. */ -+ (void)sleepForNMilliseconds: (unsigned int)msecs; ++ (void)sleepUntilDate: (OFDate*)date; /** * Yields a processor voluntarily and moves the thread at the end of the queue * for its priority. */