@@ -72,11 +72,11 @@ } _running; # ifndef OF_OBJFW_RUNTIME void *_pool; # endif # ifdef OF_HAVE_BLOCKS - OFThreadBlock _Nullable _threadBlock; + OFThreadBlock _Nullable _block; # endif jmp_buf _exitEnv; id _returnValue; bool _supportsSockets; OFRunLoop *_Nullable _runLoop; @@ -116,11 +116,11 @@ # ifdef OF_HAVE_BLOCKS /** * @brief The block to execute in the thread. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThreadBlock threadBlock; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThreadBlock block; # endif /** * @brief The run loop for the thread. */ @@ -132,26 +132,36 @@ * @note This has to be set before the thread is started! * * This is a value between -1.0 (meaning lowest priority that still schedules) * and +1.0 (meaning highest priority that still allows getting preempted) * with normal priority being 0.0 (meaning being the same as the main thread). + * + * @throw OFThreadStillRunningException The thread is already/still running and + * thus the priority cannot be changed */ @property (nonatomic) float priority; /** * @brief The stack size of the thread. * * @note This has to be set before the thread is started! + * + * @throw OFThreadStillRunningException The thread is already/still running and + * thus the stack size cannot be changed */ @property (nonatomic) size_t stackSize; /** * @brief Whether the thread supports sockets. * * Some operating systems such as AmigaOS need special per-thread * initialization of sockets. If you intend to use sockets in the thread, set * this property to true before starting the thread. + * + * @throw OFThreadStillRunningException The thread is already/still running and + * thus the sockets support cannot be + * enabled/disabled */ @property (nonatomic) bool supportsSockets; /** * @brief Creates a new thread. @@ -162,14 +172,14 @@ # ifdef OF_HAVE_BLOCKS /** * @brief Creates a new thread with the specified block. * - * @param threadBlock A block which is executed by the thread + * @param block A block which is executed by the thread * @return A new, autoreleased thread */ -+ (instancetype)threadWithThreadBlock: (OFThreadBlock)threadBlock; ++ (instancetype)threadWithBlock: (OFThreadBlock)block; # endif /** * @brief Returns the current thread. * @@ -201,14 +211,17 @@ #endif #ifdef OF_HAVE_SOCKETS /** * @brief Returns the DNS resolver for the current thread. + * + * Constructs the DNS resolver is there is none yet, unless @ref currentThread + * is `nil`, in which case it returns `nil`. * * @return The DNS resolver for the current thread */ -+ (OFDNSResolver *)DNSResolver; ++ (nullable OFDNSResolver *)DNSResolver; #endif /** * @brief Suspends execution of the current thread for the specified time * interval. @@ -238,10 +251,11 @@ /** * @brief Terminates the current thread, letting it return the specified object. * * @param object The object which the terminated thread will return + * @throw OFInvalidArgumentException The method was called from the main thread */ + (void)terminateWithObject: (nullable id)object OF_NO_RETURN; /** * @brief Sets the name of the current thread. @@ -262,14 +276,14 @@ # ifdef OF_HAVE_BLOCKS /** * @brief Initializes an already allocated thread with the specified block. * - * @param threadBlock A block which is executed by the thread + * @param block A block which is executed by the thread * @return An initialized OFThread. */ -- (instancetype)initWithThreadBlock: (OFThreadBlock)threadBlock; +- (instancetype)initWithBlock: (OFThreadBlock)block; # endif /** * @brief The main routine of the thread. You need to reimplement this! * @@ -285,20 +299,24 @@ */ - (void)handleTermination OF_REQUIRES_SUPER; /** * @brief Starts the thread. + * + * @throw OFStartThreadFailedException Starting the thread failed + * @throw OFThreadStillRunningException The thread is still running */ - (void)start; /** * @brief Joins a thread. * * @return The object returned by the main method of the thread. + * @throw OFJoinThreadFailedException Joining the thread failed */ - (id)join; #else - (instancetype)init OF_UNAVAILABLE; #endif @end OF_ASSUME_NONNULL_END