@@ -13,26 +13,20 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" + #ifdef OF_HAVE_THREADS -# import "OFTLSKey.h" - # import "threading.h" #endif -/* Haiku used to define this for some unknown reason which causes trouble */ -#ifdef protected -# undef protected -#endif - /*! @file */ @class OFDate; -@class OFSortedList; @class OFRunLoop; +@class OFMutableDictionary; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_BLOCKS) /*! * @brief A block to be executed in a new thread. * @@ -71,10 +65,11 @@ of_thread_block_t _threadBlock; # endif id _returnValue; OFRunLoop *_runLoop; OFString *_name; + OFMutableDictionary *_threadDictionary; } # ifdef OF_HAVE_PROPERTIES # ifdef OF_HAVE_BLOCKS @property (copy) of_thread_block_t threadBlock; @@ -97,36 +92,10 @@ * @return A new, autoreleased thread */ + (instancetype)threadWithThreadBlock: (of_thread_block_t)threadBlock; # endif -/*! - * @brief Sets the Thread Local Storage for the specified key. - * - * The specified object is first retained and then the object stored before is - * 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 object The object the Thread Local Storage key will be set to - */ -+ (void)setObject: (id)object - forTLSKey: (OFTLSKey*)key; - -/*! - * @brief Returns the object for the specified Thread Local Storage key or nil - * if the key does not exist. - * - * @warning The returned object is *not* retained and autoreleased for - * performance reasons! - * - * @param key The Thread Local Storage key - * @return The object for the specified Thread Local Storage key or nil if the - * key does not exist. - */ -+ (id)objectForTLSKey: (OFTLSKey*)key; - /*! * @brief Returns the current thread. * * @return The current thread */ @@ -136,10 +105,18 @@ * @brief Returns the main thread. * * @return The main thread */ + (OFThread*)mainThread; + +/*! + * @brief Returns a dictionary to store thread-specific data, meaning it + * returns a different dictionary for every thread. + * + * @return A dictionary to store thread-specific data. + */ ++ (OFMutableDictionary*)threadDictionary; #endif /*! * @brief Suspends execution of the current thread for the specified time * interval.