ObjFW  Diff

Differences From Artifact [f7752f3f82]:

To Artifact [e0fcf68d56]:


71
72
73
74
75
76
77
78
79


80
81
82
83
84
85
86
71
72
73
74
75
76
77


78
79
80
81
82
83
84
85
86







-
-
+
+







	[super dealloc];
}

- (void)of_addObject: (id)object
      fileDescriptor: (int)fd
	      events: (short)events
{
	struct pollfd *FDs = [_FDs items];
	size_t count = [_FDs count];
	struct pollfd *FDs = _FDs.mutableItems;
	size_t count = _FDs.count;
	bool found = false;

	for (size_t i = 0; i < count; i++) {
		if (FDs[i].fd == fd) {
			FDs[i].events |= events;
			found = true;
			break;
102
103
104
105
106
107
108
109
110


111
112
113
114
115
116
117
102
103
104
105
106
107
108


109
110
111
112
113
114
115
116
117







-
-
+
+







	}
}

- (void)of_removeObject: (id)object
	 fileDescriptor: (int)fd
		 events: (short)events
{
	struct pollfd *FDs = [_FDs items];
	size_t nFDs = [_FDs count];
	struct pollfd *FDs = _FDs.mutableItems;
	size_t nFDs = _FDs.count;

	for (size_t i = 0; i < nFDs; i++) {
		if (FDs[i].fd == fd) {
			FDs[i].events &= ~events;

			if (FDs[i].events == 0) {
				/*
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139

140
141
142
143
144
145
146

147
148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169


170
171
172
173
174
175
176
125
126
127
128
129
130
131

132
133
134
135
136
137
138

139
140
141
142
143
144
145

146
147
148
149
150
151
152

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167


168
169
170
171
172
173
174
175
176







-
+






-
+






-
+






-
+














-
-
+
+







		}
	}
}

- (void)of_addObjectForReading: (id <OFReadyForReadingObserving>)object
{
	[self of_addObject: object
	    fileDescriptor: [object fileDescriptorForReading]
	    fileDescriptor: object.fileDescriptorForReading
		    events: POLLIN];
}

- (void)of_addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
	[self of_addObject: object
	    fileDescriptor: [object fileDescriptorForWriting]
	    fileDescriptor: object.fileDescriptorForWriting
		    events: POLLOUT];
}

- (void)of_removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
	[self of_removeObject: object
	       fileDescriptor: [object fileDescriptorForReading]
	       fileDescriptor: object.fileDescriptorForReading
		       events: POLLIN];
}

- (void)of_removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
	[self of_removeObject: object
	       fileDescriptor: [object fileDescriptorForWriting]
	       fileDescriptor: object.fileDescriptorForWriting
		       events: POLLOUT];
}

- (void)observeForTimeInterval: (of_time_interval_t)timeInterval
{
	struct pollfd *FDs;
	int events;
	size_t nFDs;

	[self of_processQueue];

	if ([self of_processReadBuffers])
		return;

	FDs = [_FDs items];
	nFDs = [_FDs count];
	FDs = _FDs.mutableItems;
	nFDs = _FDs.count;

#ifdef OPEN_MAX
	if (nFDs > OPEN_MAX)
		@throw [OFOutOfRangeException exception];
#endif

	events = poll(FDs, (nfds_t)nFDs,