Overview
Comment: | Don't use a spinlock for reference counting if we have no threads. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9454c38313cb4fe9363e775a7ca979b5 |
User & Date: | js on 2011-10-24 15:00:45 |
Other Links: | manifest | tags |
Context
2011-10-24
| ||
15:47 | Make sure the fullness of a hashtable is always at max 3/4. check-in: 1bec445dd2 user: js tags: trunk | |
15:00 | Don't use a spinlock for reference counting if we have no threads. check-in: 9454c38313 user: js tags: trunk | |
2011-10-22
| ||
17:06 | Fix libobjc version check. check-in: 79b09ea934 user: js tags: trunk | |
Changes
Modified src/OFObject.m from [6a6eeb3258] to [34b558d1e8].
︙ | ︙ | |||
58 59 60 61 62 63 64 | # import "threading.h" #endif struct pre_ivar { void **memoryChunks; unsigned int memoryChunksSize; int32_t retainCount; | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # import "threading.h" #endif struct pre_ivar { void **memoryChunks; unsigned int memoryChunksSize; int32_t retainCount; #if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) of_spinlock_t retainCountSpinlock; #endif }; /* Hopefully no arch needs more than 16 bytes padding */ #ifndef __BIGGEST_ALIGNMENT__ # define __BIGGEST_ALIGNMENT__ 16 |
︙ | ︙ | |||
190 191 192 193 194 195 196 | @throw (OFAllocFailedException*)&alloc_failed_exception; } ((struct pre_ivar*)instance)->memoryChunks = NULL; ((struct pre_ivar*)instance)->memoryChunksSize = 0; ((struct pre_ivar*)instance)->retainCount = 1; | | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | @throw (OFAllocFailedException*)&alloc_failed_exception; } ((struct pre_ivar*)instance)->memoryChunks = NULL; ((struct pre_ivar*)instance)->memoryChunksSize = 0; ((struct pre_ivar*)instance)->retainCount = 1; #if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) if (!of_spinlock_new( &((struct pre_ivar*)instance)->retainCountSpinlock)) { free(instance); @throw [OFInitializationFailedException exceptionWithClass: self]; } #endif |
︙ | ︙ | |||
1007 1008 1009 1010 1011 1012 1013 | pointer: pointer]; } - retain { #if defined(OF_ATOMIC_OPS) of_atomic_inc_32(&PRE_IVAR->retainCount); | | > > | | > > > | 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | pointer: pointer]; } - retain { #if defined(OF_ATOMIC_OPS) of_atomic_inc_32(&PRE_IVAR->retainCount); #elif defined(OF_THREADS) assert(of_spinlock_lock(&PRE_IVAR->retainCountSpinlock)); PRE_IVAR->retainCount++; assert(of_spinlock_unlock(&PRE_IVAR->retainCountSspinlock)); #else PRE_IVAR->retainCount++; #endif return self; } - (unsigned int)retainCount { assert(PRE_IVAR->retainCount >= 0); return PRE_IVAR->retainCount; } - (void)release { #if defined(OF_ATOMIC_OPS) if (of_atomic_dec_32(&PRE_IVAR->retainCount) <= 0) [self dealloc]; #elif defined(OF_THREADS) size_t c; assert(of_spinlock_lock(&PRE_IVAR->retainCountSpinlock)); c = --PRE_IVAR->retainCount; assert(of_spinlock_unlock(&PRE_IVAR->retainCountSpinlock)); if (c == 0) [self dealloc]; #else if (--PRE_IVAR->retainCount == 0) [self dealloc]; #endif } - autorelease { /* |
︙ | ︙ |