Diff

Not logged in

Differences From Artifact [7523e6d739]:

To Artifact [8c6dcd3941]:


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
16
17
18
19
20
21
22





23
24






25
26
27
28
29
30

31

32
33
34
35
36
37
38







-
-
-
-
-


-
-
-
-
-
-






-
+
-







#import "OFAutoreleasePool.h"
#import "OFList.h"
#import "OFThread.h"
#import "OFExceptions.h"

#import "threading.h"

/*
 * Pay special attention to NULL and nil in this file, they might be different!
 * Use NULL for TLS values and nil for instance variables.
 */

static of_tlskey_t first_key, last_key;

static void
release_all(id obj)
{
	[of_tlskey_get(first_key) release];
}

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

	if (!of_tlskey_new(&first_key, release_all) ||
	if (!of_tlskey_new(&first_key) || !of_tlskey_new(&last_key))
	    !of_tlskey_new(&last_key, NULL))
		@throw [OFInitializationFailedException newWithClass: self];
}

+ (void)addObjectToTopmostPool: (OFObject*)obj
{
	id last = of_tlskey_get(last_key);

67
68
69
70
71
72
73





74
75
76
77
78
79
80
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73







+
+
+
+
+







	@try {
		[last addObject: obj];
	} @catch (OFException *e) {
		[obj release];
		@throw e;
	}
}

+ (void)releaseAll
{
	[of_tlskey_get(first_key) release];
}

- init
{
	id first;

	self = [super init];