ObjFW  Check-in [cc9601c228]

Overview
Comment:Make sure an autorelease pool is always in place.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cc9601c2281458052c30546c9ef9778e3efd299e74bb64b289237e1a79b13e53
User & Date: js on 2012-09-16 22:16:47
Other Links: manifest | tags
Context
2012-09-16
22:26
Every OFThread now always has a run loop. check-in: 4c8f9edda8 user: js tags: trunk
22:16
Make sure an autorelease pool is always in place. check-in: cc9601c228 user: js tags: trunk
21:59
Make it possible to invalidate OFTimers. check-in: 8658d1a22a user: js tags: trunk
Changes

Modified src/OFAutoreleasePool.h from [fd7231bed2] to [cce576bf12].

64
65
66
67
68
69
70








- (void)release;

/**
 * \brief Releases all objects in the autorelease pool and deallocates the pool.
 */
- (void)drain;
@end















>
>
>
>
>
>
>
>
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
- (void)release;

/**
 * \brief Releases all objects in the autorelease pool and deallocates the pool.
 */
- (void)drain;
@end

#ifdef __cplusplus
extern "C" {
#endif
extern id of_autorelease(id);
#ifdef __cplusplus
}
#endif

Modified src/OFAutoreleasePool.m from [ef9f34b1d7] to [f049b285d4].

36
37
38
39
40
41
42













43
44
45
46
47
48
49

#ifdef OF_COMPILER_TLS
static __thread void *first = NULL;
static __thread OFAutoreleasePool **cache = NULL;
#else
static of_tlskey_t firstKey, cacheKey;
#endif














@implementation OFAutoreleasePool
#ifndef OF_COMPILER_TLS
+ (void)initialize
{
	if (self != [OFAutoreleasePool class])
		return;







>
>
>
>
>
>
>
>
>
>
>
>
>







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

#ifdef OF_COMPILER_TLS
static __thread void *first = NULL;
static __thread OFAutoreleasePool **cache = NULL;
#else
static of_tlskey_t firstKey, cacheKey;
#endif

id
of_autorelease(id object)
{
#ifndef OF_COMPILER_TLS
	void *first = of_tlskey_get(firstKey);
#endif

	if (first == NULL)
		[[OFAutoreleasePool alloc] init];

	return _objc_rootAutorelease(object);
}

@implementation OFAutoreleasePool
#ifndef OF_COMPILER_TLS
+ (void)initialize
{
	if (self != [OFAutoreleasePool class])
		return;
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	}

	return [super alloc];
}

+ (id)addObject: (id)object
{
#ifndef OF_COMPILER_TLS
	void *first = of_tlskey_get(firstKey);
#endif

	if (first == NULL)
		[[OFAutoreleasePool alloc] init];

	return _objc_rootAutorelease(object);
}

+ (void)OF_releaseAll
{
#ifndef OF_COMPILER_TLS
	void *first = of_tlskey_get(firstKey);
#endif







<
<
<
<
<
<
<
|







86
87
88
89
90
91
92







93
94
95
96
97
98
99
100
	}

	return [super alloc];
}

+ (id)addObject: (id)object
{







	return of_autorelease(object);
}

+ (void)OF_releaseAll
{
#ifndef OF_COMPILER_TLS
	void *first = of_tlskey_get(firstKey);
#endif

Modified src/OFObject.m from [2de861858b] to [5eddd9378d].

30
31
32
33
34
35
36

37
38
39
40
41
42
43
# include <sys/syspage.h>
#endif

#import "OFObject.h"
#import "OFTimer.h"
#import "OFThread.h"
#import "OFRunLoop.h"


#import "OFAllocFailedException.h"
#import "OFEnumerationMutationException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFMemoryNotPartOfObjectException.h"
#import "OFNotImplementedException.h"







>







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# include <sys/syspage.h>
#endif

#import "OFObject.h"
#import "OFTimer.h"
#import "OFThread.h"
#import "OFRunLoop.h"
#import "OFAutoreleasePool.h"

#import "OFAllocFailedException.h"
#import "OFEnumerationMutationException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFMemoryNotPartOfObjectException.h"
#import "OFNotImplementedException.h"
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
	id (*imp)(id, SEL, id) =
	    (id(*)(id, SEL, id))[self methodForSelector: selector];

	return imp(self, selector, object);
}

- (id)performSelector: (SEL)selector
	   withObject: (id)object
	   withObject: (id)otherObject
{
	id (*imp)(id, SEL, id, id) =
	    (id(*)(id, SEL, id, id))[self methodForSelector: selector];

	return imp(self, selector, object, otherObject);
}

- (void)performSelector: (SEL)selector
	     afterDelay: (double)delay
{
	void *pool = objc_autoreleasePoolPush();








|
|




|







568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
	id (*imp)(id, SEL, id) =
	    (id(*)(id, SEL, id))[self methodForSelector: selector];

	return imp(self, selector, object);
}

- (id)performSelector: (SEL)selector
	   withObject: (id)object1
	   withObject: (id)object2
{
	id (*imp)(id, SEL, id, id) =
	    (id(*)(id, SEL, id, id))[self methodForSelector: selector];

	return imp(self, selector, object1, object2);
}

- (void)performSelector: (SEL)selector
	     afterDelay: (double)delay
{
	void *pool = objc_autoreleasePoolPush();

881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
	if (--PRE_IVAR->retainCount == 0)
		[self dealloc];
#endif
}

- autorelease
{
	return _objc_rootAutorelease(self);
}

- self
{
	return self;
}








|







882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
	if (--PRE_IVAR->retainCount == 0)
		[self dealloc];
#endif
}

- autorelease
{
	return of_autorelease(self);
}

- self
{
	return self;
}