Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -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. */ @@ -162,14 +162,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 +201,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. @@ -262,14 +265,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! * Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -131,12 +131,12 @@ * Nasty workaround for thread implementations which can't return a * pointer on join, or don't have a way to exit a thread. */ if (setjmp(thread->_exitEnv) == 0) { # ifdef OF_HAVE_BLOCKS - if (thread->_threadBlock != NULL) - thread->_returnValue = [thread->_threadBlock() retain]; + if (thread->_block != NULL) + thread->_returnValue = [thread->_block() retain]; else # endif thread->_returnValue = [[thread main] retain]; } @@ -158,11 +158,11 @@ [thread release]; } @synthesize name = _name; # ifdef OF_HAVE_BLOCKS -@synthesize threadBlock = _threadBlock; +@synthesize block = _block; # endif + (void)initialize { if (self != [OFThread class]) @@ -177,13 +177,13 @@ { return [[[self alloc] init] autorelease]; } # ifdef OF_HAVE_BLOCKS -+ (instancetype)threadWithThreadBlock: (OFThreadBlock)threadBlock ++ (instancetype)threadWithBlock: (OFThreadBlock)block { - return [[[self alloc] initWithThreadBlock: threadBlock] autorelease]; + return [[[self alloc] initWithBlock: block] autorelease]; } # endif + (OFThread *)currentThread { @@ -378,16 +378,16 @@ return self; } # ifdef OF_HAVE_BLOCKS -- (instancetype)initWithThreadBlock: (OFThreadBlock)threadBlock +- (instancetype)initWithBlock: (OFThreadBlock)block { self = [self init]; @try { - _threadBlock = [threadBlock copy]; + _block = [block copy]; } @catch (id e) { [self release]; @throw e; } @@ -541,11 +541,11 @@ if (_running == OFThreadStateWaitingForJoin) OFPlainThreadDetach(_thread); [_returnValue release]; # ifdef OF_HAVE_BLOCKS - [_threadBlock release]; + [_block release]; # endif [super dealloc]; } #else