@@ -14,13 +14,12 @@ */ #include #import "OFObject.h" - #ifdef OF_HAVE_THREADS -# import "thread.h" +# import "OFPlainThread.h" #endif OF_ASSUME_NONNULL_BEGIN /** @file */ @@ -36,11 +35,11 @@ /** * @brief A block to be executed in a new thread. * * @return The object which should be returned when the thread is joined */ -typedef id _Nullable (^of_thread_block_t)(void); +typedef id _Nullable (^OFThreadBlock)(void); #endif /** * @class OFThread OFThread.h ObjFW/OFThread.h * @@ -62,22 +61,22 @@ @interface OFThread: OFObject #ifdef OF_HAVE_THREADS { @private - of_thread_t _thread; - of_thread_attr_t _attr; - enum of_thread_running { - OF_THREAD_NOT_RUNNING, - OF_THREAD_RUNNING, - OF_THREAD_WAITING_FOR_JOIN + OFPlainThread _thread; + OFPlainThreadAttributes _attr; + enum OFThreadState { + OFThreadStateNotRunning, + OFThreadStateRunning, + OFThreadStateWaitingForJoin } _running; # ifndef OF_OBJFW_RUNTIME void *_pool; # endif # ifdef OF_HAVE_BLOCKS - of_thread_block_t _Nullable _threadBlock; + OFThreadBlock _Nullable _threadBlock; # endif jmp_buf _exitEnv; id _returnValue; bool _supportsSockets; OFRunLoop *_Nullable _runLoop; @@ -117,12 +116,11 @@ # ifdef OF_HAVE_BLOCKS /** * @brief The block to execute in the thread. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) - of_thread_block_t threadBlock; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThreadBlock threadBlock; # endif /** * @brief The run loop for the thread. */ @@ -167,11 +165,11 @@ * @brief Creates a new thread with the specified block. * * @param threadBlock A block which is executed by the thread * @return A new, autoreleased thread */ -+ (instancetype)threadWithThreadBlock: (of_thread_block_t)threadBlock; ++ (instancetype)threadWithThreadBlock: (OFThreadBlock)threadBlock; # endif /** * @brief Returns the current thread. * @@ -215,11 +213,11 @@ * @brief Suspends execution of the current thread for the specified time * interval. * * @param timeInterval The number of seconds to sleep */ -+ (void)sleepForTimeInterval: (of_time_interval_t)timeInterval; ++ (void)sleepForTimeInterval: (OFTimeInterval)timeInterval; /** * @brief Suspends execution of the current thread until the specified date. * * @param date The date to wait for @@ -267,11 +265,11 @@ * @brief Initializes an already allocated thread with the specified block. * * @param threadBlock A block which is executed by the thread * @return An initialized OFThread. */ -- (instancetype)initWithThreadBlock: (of_thread_block_t)threadBlock; +- (instancetype)initWithThreadBlock: (OFThreadBlock)threadBlock; # endif /** * @brief The main routine of the thread. You need to reimplement this! *