Overview
Comment: | OFThread: Rename threadBlock to block |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0cca95da46acddcfe92f13db4e15e955 |
User & Date: | js on 2022-08-29 20:15:22 |
Other Links: | manifest | tags |
Context
2022-08-29
| ||
20:35 | OFXMLProcessingInstruction: Rename data -> text check-in: fbcbf30be7 user: js tags: trunk | |
20:15 | OFThread: Rename threadBlock to block check-in: 0cca95da46 user: js tags: trunk | |
2022-08-27
| ||
23:53 | OFArchiveEntry: Add more properties check-in: 406134b5e2 user: js tags: trunk | |
Changes
Modified src/OFThread.h from [edfcfa680d] to [878e01b6fc].
︙ | ︙ | |||
70 71 72 73 74 75 76 | OFThreadStateRunning, OFThreadStateWaitingForJoin } _running; # ifndef OF_OBJFW_RUNTIME void *_pool; # endif # ifdef OF_HAVE_BLOCKS | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | OFThreadStateRunning, OFThreadStateWaitingForJoin } _running; # ifndef OF_OBJFW_RUNTIME void *_pool; # endif # ifdef OF_HAVE_BLOCKS OFThreadBlock _Nullable _block; # endif jmp_buf _exitEnv; id _returnValue; bool _supportsSockets; OFRunLoop *_Nullable _runLoop; OFMutableDictionary *_threadDictionary; OFString *_Nullable _name; |
︙ | ︙ | |||
114 115 116 117 118 119 120 | */ @property OF_NULLABLE_PROPERTY (copy) OFString *name; # ifdef OF_HAVE_BLOCKS /** * @brief The block to execute in the thread. */ | | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | */ @property OF_NULLABLE_PROPERTY (copy) OFString *name; # ifdef OF_HAVE_BLOCKS /** * @brief The block to execute in the thread. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThreadBlock block; # endif /** * @brief The run loop for the thread. */ @property (readonly, nonatomic) OFRunLoop *runLoop; |
︙ | ︙ | |||
160 161 162 163 164 165 166 | */ + (instancetype)thread; # ifdef OF_HAVE_BLOCKS /** * @brief Creates a new thread with the specified block. * | | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | */ + (instancetype)thread; # ifdef OF_HAVE_BLOCKS /** * @brief Creates a new thread with the specified block. * * @param block A block which is executed by the thread * @return A new, autoreleased thread */ + (instancetype)threadWithBlock: (OFThreadBlock)block; # endif /** * @brief Returns the current thread. * * @return The current thread */ |
︙ | ︙ | |||
199 200 201 202 203 204 205 206 207 208 | */ + (nullable OFMutableDictionary *)threadDictionary; #endif #ifdef OF_HAVE_SOCKETS /** * @brief Returns the DNS resolver for the current thread. * * @return The DNS resolver for the current thread */ | > > > | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | */ + (nullable OFMutableDictionary *)threadDictionary; #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 */ + (nullable OFDNSResolver *)DNSResolver; #endif /** * @brief Suspends execution of the current thread for the specified time * interval. * * @param timeInterval The number of seconds to sleep |
︙ | ︙ | |||
260 261 262 263 264 265 266 | */ + (nullable OFString *)name; # ifdef OF_HAVE_BLOCKS /** * @brief Initializes an already allocated thread with the specified block. * | | | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | */ + (nullable OFString *)name; # ifdef OF_HAVE_BLOCKS /** * @brief Initializes an already allocated thread with the specified block. * * @param block A block which is executed by the thread * @return An initialized OFThread. */ - (instancetype)initWithBlock: (OFThreadBlock)block; # endif /** * @brief The main routine of the thread. You need to reimplement this! * * @return The object the join method should return when called for this thread */ |
︙ | ︙ |
Modified src/OFThread.m from [9e6c736b19] to [51c302d474].
︙ | ︙ | |||
129 130 131 132 133 134 135 | /* * 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 | | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /* * 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->_block != NULL) thread->_returnValue = [thread->_block() retain]; else # endif thread->_returnValue = [[thread main] retain]; } [thread handleTermination]; |
︙ | ︙ | |||
156 157 158 159 160 161 162 | thread->_running = OFThreadStateWaitingForJoin; [thread release]; } @synthesize name = _name; # ifdef OF_HAVE_BLOCKS | | | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | thread->_running = OFThreadStateWaitingForJoin; [thread release]; } @synthesize name = _name; # ifdef OF_HAVE_BLOCKS @synthesize block = _block; # endif + (void)initialize { if (self != [OFThread class]) return; if (OFTLSKeyNew(&threadSelfKey) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)thread { return [[[self alloc] init] autorelease]; } # ifdef OF_HAVE_BLOCKS + (instancetype)threadWithBlock: (OFThreadBlock)block { return [[[self alloc] initWithBlock: block] autorelease]; } # endif + (OFThread *)currentThread { return OFTLSKeyGet(threadSelfKey); } |
︙ | ︙ | |||
376 377 378 379 380 381 382 | @throw e; } return self; } # ifdef OF_HAVE_BLOCKS | | | | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | @throw e; } return self; } # ifdef OF_HAVE_BLOCKS - (instancetype)initWithBlock: (OFThreadBlock)block { self = [self init]; @try { _block = [block copy]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
539 540 541 542 543 544 545 | * the resources. */ if (_running == OFThreadStateWaitingForJoin) OFPlainThreadDetach(_thread); [_returnValue release]; # ifdef OF_HAVE_BLOCKS | | | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | * the resources. */ if (_running == OFThreadStateWaitingForJoin) OFPlainThreadDetach(_thread); [_returnValue release]; # ifdef OF_HAVE_BLOCKS [_block release]; # endif [super dealloc]; } #else - (instancetype)init { OF_INVALID_INIT_METHOD } #endif @end |