ObjFW  Diff

Differences From Artifact [dc0778aa90]:

  • File src/OFKernelEventObserver_LockedQueue.m — part of check-in [e9b4700cb6] at 2015-12-29 21:33:07 on branch trunk — Refactor OFKernelEventObserver

    This moves the locked queue for actions to
    OFKernelEventObserver_LockedQueue, which is now used for select and
    poll, but skipped for kqueue and epoll, as they natively support changes
    from another thread.

    This fixes the problem that removing an object is delayed until the next
    observe call - at which point it might have already been closed, meaning
    the fd is no longer available. This was mainly a problem with kqueue, as
    closing the fd already removed it from the kqueue, which then resulted
    in an error being returned when trying to manually remove the fd from
    the kqueue. (user: js, size: 4890) [annotate] [blame] [check-ins using] [more...]

To Artifact [bec31b0210]:


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
	self = [super init];

	@try {
		_queueActions = [[OFDataArray alloc]
		    initWithItemSize: sizeof(int)];
		_queueFDs = [[OFDataArray alloc] initWithItemSize: sizeof(int)];
		_queueObjects = [[OFMutableArray alloc] init];

#ifdef OF_HAVE_THREADS
		_mutex = [[OFMutex alloc] init];
#endif
	} @catch (id e) {
		@throw [OFInitializationFailedException
		    exceptionWithClass: [self class]];
	}

	return self;
}

- (void)dealloc
{
	[_queueActions release];
	[_queueFDs release];
	[_queueObjects release];
#ifdef OF_HAVE_THREADS
	[_mutex release];
#endif

	[super dealloc];
}

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







<
<
<
<













<
<
<







39
40
41
42
43
44
45




46
47
48
49
50
51
52
53
54
55
56
57
58



59
60
61
62
63
64
65
	self = [super init];

	@try {
		_queueActions = [[OFDataArray alloc]
		    initWithItemSize: sizeof(int)];
		_queueFDs = [[OFDataArray alloc] initWithItemSize: sizeof(int)];
		_queueObjects = [[OFMutableArray alloc] init];




	} @catch (id e) {
		@throw [OFInitializationFailedException
		    exceptionWithClass: [self class]];
	}

	return self;
}

- (void)dealloc
{
	[_queueActions release];
	[_queueFDs release];
	[_queueObjects release];




	[super dealloc];
}

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