Overview
Comment: | Copy the object for an OFThread so it's thread-safe. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9b3d408f0df5e78d0879da79a044e30c |
User & Date: | js on 2009-06-01 01:46:22 |
Other Links: | manifest | tags |
Context
2009-06-01
| ||
02:08 | Add OFMutex and use it in OFTCPSocket instead of @synchronized. check-in: cca028cedf user: js tags: trunk | |
01:46 | Copy the object for an OFThread so it's thread-safe. check-in: 9b3d408f0d user: js tags: trunk | |
01:44 |
It's far more likely the lock we search is at the end. Additionally, add tests for objc_sync_*. check-in: 4b03ccfe1f user: js tags: trunk | |
Changes
Modified src/OFThread.h from [5e60e220d4] to [b93a3d71df].
︙ | ︙ | |||
59 60 61 62 63 64 65 | @public id retval; #endif } /** | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | @public id retval; #endif } /** * \param obj An object that is passed to the main method as a copy * \return A new, autoreleased thread */ + threadWithObject: (id)obj; /** * Sets the Thread Local Storage for the specified key. * |
︙ | ︙ | |||
85 86 87 88 89 90 91 | * Returns the object for the specified Thread Local Storage key. * * \param key The Thread Local Storage key */ + (id)objectForTLSKey: (OFTLSKey*)key; /** | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | * Returns the object for the specified Thread Local Storage key. * * \param key The Thread Local Storage key */ + (id)objectForTLSKey: (OFTLSKey*)key; /** * \param obj An object that is passed to the main method as a copy * \return An initialized OFThread. */ - initWithObject: (id)obj; /** * The main routine of the thread. You need to reimplement this! * |
︙ | ︙ |
Modified src/OFThread.m from [d1dce164e0] to [919a81fa63].
︙ | ︙ | |||
79 80 81 82 83 84 85 | } - initWithObject: (id)obj { Class c; self = [super init]; | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | } - initWithObject: (id)obj { Class c; self = [super init]; object = [obj copy]; #ifndef _WIN32 if (pthread_create(&thread, NULL, call_main, self)) { #else if ((thread = CreateThread(NULL, 0, call_main, self, 0, NULL)) == NULL) { #endif |
︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 | #else if (thread != INVALID_HANDLE_VALUE) { TerminateThread(thread, 1); CloseHandle(thread); } #endif [super dealloc]; } @end @implementation OFTLSKey + tlsKeyWithDestructor: (void(*)(void*))destructor { | > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #else if (thread != INVALID_HANDLE_VALUE) { TerminateThread(thread, 1); CloseHandle(thread); } #endif [object release]; [super dealloc]; } @end @implementation OFTLSKey + tlsKeyWithDestructor: (void(*)(void*))destructor { |
︙ | ︙ |