ObjFW  Diff

Differences From Artifact [646227ddee]:

To Artifact [f5145d052f]:


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import "OFSortedList.h"
#import "OFTimer.h"
#import "OFDate.h"

#import "autorelease.h"
#import "macros.h"

static OFTLSKey *currentRunLoopKey;
static OFRunLoop *mainRunLoop;

#ifdef OF_HAVE_BLOCKS
@interface OFRunLoop_ReadQueueItem: OFObject
{
	void *buffer;
	size_t length;
	of_stream_async_read_block_t block;







<
|







24
25
26
27
28
29
30

31
32
33
34
35
36
37
38
#import "OFSortedList.h"
#import "OFTimer.h"
#import "OFDate.h"

#import "autorelease.h"
#import "macros.h"


static OFRunLoop *mainRunLoop = nil;

#ifdef OF_HAVE_BLOCKS
@interface OFRunLoop_ReadQueueItem: OFObject
{
	void *buffer;
	size_t length;
	of_stream_async_read_block_t block;
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

113
114
115
116
117
118
119


120
121
122
123
124
125

126
127
128

129
130
131
132
133
134
135

	[super dealloc];
}
@end
#endif

@implementation OFRunLoop
+ (void)initialize
{
	if (self == [OFRunLoop class])
		currentRunLoopKey = [[OFTLSKey alloc] init];
}

+ (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







<
<
<
<
<
<







>
|

|
<
|
<
|
>
>

|


|

>
|
<
<
>







92
93
94
95
96
97
98






99
100
101
102
103
104
105
106
107
108
109

110

111
112
113
114
115
116
117
118
119
120
121


122
123
124
125
126
127
128
129

	[super dealloc];
}
@end
#endif

@implementation OFRunLoop






+ (OFRunLoop*)mainRunLoop
{
	return [[mainRunLoop retain] autorelease];
}

+ (OFRunLoop*)currentRunLoop
{
	OFThread *currentThread = [OFThread currentThread];
	OFRunLoop *runLoop = [currentThread runLoop];

	if (runLoop != nil)

		return runLoop;


	runLoop = [[[OFRunLoop alloc] init] autorelease];
	[currentThread _setRunLoop: runLoop];

	return runLoop;
}

+ (void)_setMainRunLoop
{
	void *pool = objc_autoreleasePoolPush();
	mainRunLoop = [[[OFThread currentThread] runLoop] retain];


	objc_autoreleasePoolPop(pool);
}

#ifdef OF_HAVE_BLOCKS
+ (void)_addAsyncReadForStream: (OFStream*)stream
			buffer: (void*)buffer
			length: (size_t)length
			 block: (of_stream_async_read_block_t)block
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#endif

- init
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		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;
}







<
|
<





<
<







203
204
205
206
207
208
209

210

211
212
213
214
215


216
217
218
219
220
221
222
#endif

- init
{
	self = [super init];

	@try {

		timersQueue = [[OFSortedList alloc] init];


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

		readQueues = [[OFMutableDictionary alloc] init];


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

	return self;
}