ObjFW  Diff

Differences From Artifact [317802665c]:

  • File src/OFRunLoop.m — part of check-in [13eb2bf77b] at 2012-09-14 05:36:54 on branch trunk — OFRunLoop: Remove the key for the stream.

    As the stream is used as a key, this references the stream. This
    resulted in the stream never being deallocated, even though it was not
    used anymore. The advantage of not removing it was that the next async
    read on the stream would have been slightly faster by saving one malloc. (user: js, size: 6593) [annotate] [blame] [check-ins using]

To Artifact [5d28216a68]:


86
87
88
89
90
91
92
93







94
95
96
97
98
99


100
101
102
103
104
105
106
+ (OFRunLoop*)mainRunLoop
{
	return [[mainRunLoop retain] autorelease];
}

+ (OFRunLoop*)currentRunLoop
{
	return [[[OFThread objectForTLSKey: currentRunLoopKey]







	    retain] autorelease];
}

+ (void)_setMainRunLoop: (OFRunLoop*)mainRunLoop_
{
	mainRunLoop = [mainRunLoop_ retain];


}

#ifdef OF_HAVE_BLOCKS
+ (void)_addAsyncReadForStream: (OFStream*)stream
			buffer: (void*)buffer
			length: (size_t)length
			 block: (of_stream_async_read_block_t)block







|
>
>
>
>
>
>
>
|





>
>







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
+ (OFRunLoop*)mainRunLoop
{
	return [[mainRunLoop retain] autorelease];
}

+ (OFRunLoop*)currentRunLoop
{
	OFRunLoop *runLoop = [OFThread objectForTLSKey: currentRunLoopKey];

	if (runLoop == nil) {
		runLoop = [[OFRunLoop alloc] init];
		[OFThread setObject: runLoop
			  forTLSKey: currentRunLoopKey];
	}

	return [[runLoop retain] autorelease];
}

+ (void)_setMainRunLoop: (OFRunLoop*)mainRunLoop_
{
	mainRunLoop = [mainRunLoop_ retain];
	[OFThread setObject: mainRunLoop
		  forTLSKey: currentRunLoopKey];
}

#ifdef OF_HAVE_BLOCKS
+ (void)_addAsyncReadForStream: (OFStream*)stream
			buffer: (void*)buffer
			length: (size_t)length
			 block: (of_stream_async_read_block_t)block
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
		timersQueue = [[[OFThread currentThread] _timersQueue] retain];

		streamObserver = [[OFStreamObserver alloc] init];
		[streamObserver setDelegate: self];

		readQueues = [[OFMutableDictionary alloc] init];

		[OFThread setObject: self
			  forTLSKey: currentRunLoopKey];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







<
<
<







174
175
176
177
178
179
180



181
182
183
184
185
186
187
		timersQueue = [[[OFThread currentThread] _timersQueue] retain];

		streamObserver = [[OFStreamObserver alloc] init];
		[streamObserver setDelegate: self];

		readQueues = [[OFMutableDictionary alloc] init];




		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;