ObjFW  Diff

Differences From Artifact [fac1be8914]:

To Artifact [6cc4e842a3]:


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#define __NO_EXT_QNX

#include "config.h"

#include <errno.h>

#import "OFKernelEventObserver.h"
#import "OFKernelEventObserver+Private.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
#import "OFStream.h"
#import "OFStream+Private.h"
#ifndef OF_HAVE_PIPE
# import "OFStreamSocket.h"
#endif

#ifdef HAVE_KQUEUE







<



<
<
<







18
19
20
21
22
23
24

25
26
27



28
29
30
31
32
33
34
#define __NO_EXT_QNX

#include "config.h"

#include <errno.h>

#import "OFKernelEventObserver.h"

#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"



#import "OFStream.h"
#import "OFStream+Private.h"
#ifndef OF_HAVE_PIPE
# import "OFStreamSocket.h"
#endif

#ifdef HAVE_KQUEUE
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

			if (of_socket_errno() != EADDRINUSE)
				@throw [OFInitializationFailedException
				    exceptionWithClass: self.class];
		}
# endif
#endif

#ifdef OF_HAVE_THREADS
		_mutex = [[OFMutex alloc] init];
#endif

		_queueActions = [[OFMutableData alloc]
		    initWithItemSize: sizeof(int)];
		_queueObjects = [[OFMutableArray alloc] init];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







<
<
<
<
<
<
<
<







162
163
164
165
166
167
168








169
170
171
172
173
174
175

			if (of_socket_errno() != EADDRINUSE)
				@throw [OFInitializationFailedException
				    exceptionWithClass: self.class];
		}
# endif
#endif








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

	return self;
}
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
	if (_cancelFD[1] != _cancelFD[0])
		closesocket(_cancelFD[1]);
#endif

	[_readObjects release];
	[_writeObjects release];

#ifdef OF_HAVE_THREADS
	[_mutex release];
#endif

	[_queueActions release];
	[_queueObjects release];

	[super dealloc];
}

- (void)addObjectForReading: (id <OFReadyForReadingObserving>)object
{
#ifdef OF_HAVE_THREADS
	[_mutex lock];
	@try {
#endif
		int action = QUEUE_ADD | QUEUE_READ;

		[_queueActions addItem: &action];
		[_queueObjects addObject: object];
#ifdef OF_HAVE_THREADS
	} @finally {
		[_mutex unlock];
	}
#endif

	[self cancel];
}

- (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
#ifdef OF_HAVE_THREADS
	[_mutex lock];
	@try {
#endif
		int action = QUEUE_ADD | QUEUE_WRITE;

		[_queueActions addItem: &action];
		[_queueObjects addObject: object];
#ifdef OF_HAVE_THREADS
	} @finally {
		[_mutex unlock];
	}
#endif

	[self cancel];
}

- (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
#ifdef OF_HAVE_THREADS
	[_mutex lock];
	@try {
#endif
		int action = QUEUE_REMOVE | QUEUE_READ;

		[_queueActions addItem: &action];
		[_queueObjects addObject: object];
#ifdef OF_HAVE_THREADS
	} @finally {
		[_mutex unlock];
	}
#endif

	[self cancel];
}

- (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
#ifdef OF_HAVE_THREADS
	[_mutex lock];
	@try {
#endif
		int action = QUEUE_REMOVE | QUEUE_WRITE;

		[_queueActions addItem: &action];
		[_queueObjects addObject: object];
#ifdef OF_HAVE_THREADS
	} @finally {
		[_mutex unlock];
	}
#endif

	[self cancel];
}

- (void)of_addObjectForReading: (id <OFReadyForReadingObserving>)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)of_addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)of_removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)of_removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)of_processQueue
{
	void *pool = objc_autoreleasePoolPush();

#ifdef OF_HAVE_THREADS
	[_mutex lock];
	@try {
#endif
		const int *queueActions = _queueActions.items;
		id const *queueObjects = _queueObjects.objects;
		size_t count = _queueActions.count;

		OF_ENSURE(_queueObjects.count == count);

		for (size_t i = 0; i < count; i++) {
			int action = queueActions[i];
			id object = queueObjects[i];

			switch (action) {
			case QUEUE_ADD | QUEUE_READ:
				[_readObjects addObject: object];

				@try {
					[self of_addObjectForReading: object];
				} @catch (id e) {
					[_readObjects
					    removeObjectIdenticalTo: object];

					@throw e;
				}

				break;
			case QUEUE_ADD | QUEUE_WRITE:
				[_writeObjects addObject: object];

				@try {
					[self of_addObjectForWriting: object];
				} @catch (id e) {
					[_writeObjects
					    removeObjectIdenticalTo: object];

					@throw e;
				}

				break;
			case QUEUE_REMOVE | QUEUE_READ:
				[self of_removeObjectForReading: object];

				[_readObjects removeObjectIdenticalTo: object];

				break;
			case QUEUE_REMOVE | QUEUE_WRITE:
				[self of_removeObjectForWriting: object];

				[_writeObjects removeObjectIdenticalTo: object];

				break;
			default:
				OF_ENSURE(0);
			}
		}

		[_queueActions removeAllItems];
		[_queueObjects removeAllObjects];
#ifdef OF_HAVE_THREADS
	} @finally {
		[_mutex unlock];
	}
#endif

	objc_autoreleasePoolPop(pool);
}

- (bool)of_processReadBuffers
{
	bool foundInReadBuffer = false;

	for (id object in _readObjects) {







<
<
<
<
<
<
<





<
<
<
<
<
|
<
<
<
<
<
|
<

<
<
<


<
<
<
<
<
|
<
<
<
<
<
|
<

<
<
<


<
<
<
<
<
|
<
<
<
<
<
<
<
<
<




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







185
186
187
188
189
190
191







192
193
194
195
196





197





198

199



200
201





202





203

204



205
206





207









208
209
210
211



















212
























































































213
214
215
216
217
218
219
	if (_cancelFD[1] != _cancelFD[0])
		closesocket(_cancelFD[1]);
#endif

	[_readObjects release];
	[_writeObjects release];








	[super dealloc];
}

- (void)addObjectForReading: (id <OFReadyForReadingObserving>)object
{





	OF_UNRECOGNIZED_SELECTOR





}





- (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object
{





	OF_UNRECOGNIZED_SELECTOR





}





- (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object
{





	OF_UNRECOGNIZED_SELECTOR









}

- (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{



















	OF_UNRECOGNIZED_SELECTOR
























































































}

- (bool)of_processReadBuffers
{
	bool foundInReadBuffer = false;

	for (id object in _readObjects) {