Overview
Comment: | Use OFThread's TLS in OFAutoreleasePool. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2d09137a6b888b7a831c1676116a8908 |
User & Date: | js on 2009-05-04 13:01:19 |
Other Links: | manifest | tags |
Context
2009-05-04
| ||
14:19 | Make OFString a common class for all strings. check-in: 372211deb7 user: js tags: trunk | |
13:01 | Use OFThread's TLS in OFAutoreleasePool. check-in: 2d09137a6b user: js tags: trunk | |
12:57 | Add Thread Local Storage support to OFThread. check-in: 4d1d644283 user: js tags: trunk | |
Changes
Modified src/OFAutoreleasePool.m from [f928f923c8] to [c9f95c0438].
︙ | ︙ | |||
9 10 11 12 13 14 15 | * the packaging of this file. */ #import "config.h" #include <stdlib.h> | < < < < | | | < < < < < < < < < < | < < < < < < < < | < < | > | > > | | > > > < > | > > > | > | | 9 10 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 | * the packaging of this file. */ #import "config.h" #include <stdlib.h> #import "OFAutoreleasePool.h" #import "OFList.h" #import "OFThread.h" #import "OFExceptions.h" static OFTLSKey *pool_list_key; static void release_list(void *list) { of_list_object_t *first, *iter; IMP release; if ((first = [(OFList*)list first]) != NULL) release = [first->object methodFor: @selector(release)]; for (iter = first; iter != NULL; iter = iter->next) release(iter->object, @selector(release)); [(OFList*)list release]; } @implementation OFAutoreleasePool + initialize { pool_list_key = [[OFTLSKey alloc] initWithDestructor: release_list]; return self; } + (void)addToPool: (OFObject*)obj { OFList *pool_list; @try { pool_list = [OFThread objectForTLSKey: pool_list_key]; } @catch (OFNotInSetException *e) { [e free]; [[self alloc] init]; pool_list = [OFThread objectForTLSKey: pool_list_key]; } if ([pool_list last] == NULL) [[self alloc] init]; if ([pool_list last] == NULL) @throw [OFInitializationFailedException newWithClass: self]; [[pool_list last]->object addToPool: obj]; } - init { OFList *pool_list; self = [super init]; objects = nil; @try { pool_list = [OFThread objectForTLSKey: pool_list_key]; } @catch (OFNotInSetException *e) { [e free]; pool_list = [[OFList alloc] initWithoutRetainAndRelease]; [OFThread setObject: pool_list forTLSKey: pool_list_key]; [pool_list release]; } listobj = [pool_list append: self]; return self; } - free { [[OFThread objectForTLSKey: pool_list_key] remove: listobj]; return [super free]; } - addToPool: (OFObject*)obj { if (objects == nil) |
︙ | ︙ |
Modified tests/OFAutoreleasePool/OFAutoreleasePool.m from [d3298de97f] to [2541cf0951].
︙ | ︙ | |||
98 99 100 101 102 103 104 | o3 = [[[OFObject alloc] init] autorelease]; [pool1 retain]; [pool1 release]; [pool1 release]; [o3 free]; | | | 98 99 100 101 102 103 104 105 106 | o3 = [[[OFObject alloc] init] autorelease]; [pool1 retain]; [pool1 release]; [pool1 release]; [o3 free]; return (inits == 16 && retains == 2 && releases == 7 ? 0 : 1); } |