Overview
Comment: | Make sure +[OFThread sleep*] is always available.
This means that even if --disable-threads has been specified, it is |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
71d45a29d1d06423237a8c1fbfa70df4 |
User & Date: | js on 2013-04-26 20:40:43 |
Other Links: | manifest | tags |
Context
2013-04-26
| ||
21:10 | Use nanosleep() if available. check-in: db70226153 user: js tags: trunk | |
20:40 | Make sure +[OFThread sleep*] is always available. check-in: 71d45a29d1 user: js tags: trunk | |
20:18 | Only build OFProcess if available. check-in: 9965b1550e user: js tags: trunk | |
Changes
Modified src/Makefile from [fe3d6ea0fc] to [7ad86b5b2c].
︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + | OFString+Hashing.m \ OFString+JSONValue.m \ OFString+Serialization.m \ OFString+URLEncoding.m \ OFString+XMLEscaping.m \ OFString+XMLUnescaping.m \ OFSystemInfo.m \ OFThread.m \ OFTimer.m \ OFURL.m \ OFXMLAttribute.m \ OFXMLCDATA.m \ OFXMLCharacters.m \ OFXMLComment.m \ OFXMLElement.m \ |
︙ | |||
74 75 76 77 78 79 80 | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | - | OFHTTPServer.m \ OFStreamObserver.m \ OFStreamSocket.m \ OFTCPSocket.m SRCS_THREADS = OFCondition.m \ OFMutex.m \ OFRecursiveMutex.m \ |
︙ |
Modified src/OFRunLoop.m from [e463b5f0e9] to [76c781112c].
︙ | |||
19 20 21 22 23 24 25 26 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | + - | #include <assert.h> #import "OFRunLoop.h" #import "OFDictionary.h" #ifdef OF_HAVE_SOCKETS # import "OFStreamObserver.h" #endif #import "OFThread.h" #ifdef OF_HAVE_THREADS |
︙ |
Modified src/OFThread.h from [b48c7d5a0b] to [b4c8773e10].
︙ | |||
11 12 13 14 15 16 17 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | + - + - + + - + - + + + - + - + - + - + - + - - + + - + - + - + - + | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #ifdef OF_HAVE_THREADS |
︙ | |||
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 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 | + - + + - + - + | /*! * @brief Returns the main thread. * * @return The main thread */ + (OFThread*)mainThread; #endif /*! * @brief Suspends execution of the current thread for the specified time * interval. * * @param seconds The number of seconds to sleep */ + (void)sleepForTimeInterval: (double)seconds; /*! * @brief Suspends execution of the current thread until the specified date. * * @param date The date to wait for */ + (void)sleepUntilDate: (OFDate*)date; /*! |
︙ | |||
223 224 225 226 227 228 229 230 | 229 230 231 232 233 234 235 236 237 | + | /*! * @brief Sets the name for the thread. * * @param name The name for the thread */ - (void)setName: (OFString*)name; #endif @end |
Modified src/OFThread.m from [ffbd3cc3a9] to [426c027f93].
︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | + + + + - + + + - - - + + + + + + - + - + - + - + - + - + - + + + - + - + - + - + | #include "config.h" #define OF_THREAD_M #define __NO_EXT_QNX #include <stdlib.h> #include <math.h> #ifndef _WIN32 # include <unistd.h> #endif #ifdef OF_HAVE_SCHED_YIELD # include <sched.h> #endif |
︙ | |||
162 163 164 165 166 167 168 169 170 171 172 173 174 175 | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | + | return [[(id)of_tlskey_get(threadSelfKey) retain] autorelease]; } + (OFThread*)mainThread { return mainThread; } #endif + (void)sleepForTimeInterval: (double)seconds { if (seconds < 0) @throw [OFOutOfRangeException exceptionWithClass: self]; #ifndef _WIN32 |
︙ | |||
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | + - + - + - + - + | #ifdef OF_HAVE_SCHED_YIELD sched_yield(); #else [self sleepForTimeInterval: 0]; #endif } #ifdef OF_HAVE_THREADS + (void)terminate { [self terminateWithObject: nil]; } + (void)terminateWithObject: (id)object { OFThread *thread = of_tlskey_get(threadSelfKey); if (thread != nil) { thread->_returnValue = [object retain]; [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; } [OFTLSKey OF_callAllDestructors]; |
︙ | |||
326 327 328 329 330 331 332 | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | - + - + - + | - copy { return [self retain]; } - (OFRunLoop*)runLoop { |
︙ | |||
375 376 377 378 379 380 381 382 | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | + + + + + + + + + + + + + | of_thread_detach(_thread); [_returnValue release]; [_runLoop release]; [super dealloc]; } #else - init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } #endif @end |
Modified src/ObjFW.h from [459089c732] to [58cac27b30].
︙ | |||
158 159 160 161 162 163 164 165 166 | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | + - | #endif #ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif #import "OFLocking.h" #import "OFThread.h" #ifdef OF_HAVE_THREADS # import "threading.h" |