61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
116
117
118
119
120
121
122
123
124
125
126
127
128
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
116
117
118
119
120
121
122
123
124
125
126
127
128
|
-
+
-
+
-
+
-
+
|
@throw [OFOutOfRangeException exception];
_maxFD = (int)_cancelFD[0];
return self;
}
- (void)OF_addObjectForReading: (id <OFReadyForReadingObserving>)object
- (void)of_addObjectForReading: (id <OFReadyForReadingObserving>)object
{
int fd = [object fileDescriptorForReading];
if (fd < 0 || fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
if (fd > _maxFD)
_maxFD = fd;
FD_SET((of_socket_t)fd, &_readFDs);
}
- (void)OF_addObjectForWriting: (id <OFReadyForWritingObserving>)object
- (void)of_addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
int fd = [object fileDescriptorForWriting];
if (fd < 0 || fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
if (fd > _maxFD)
_maxFD = fd;
FD_SET((of_socket_t)fd, &_writeFDs);
}
- (void)OF_removeObjectForReading: (id <OFReadyForReadingObserving>)object
- (void)of_removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
/* TODO: Adjust _maxFD */
int fd = [object fileDescriptorForReading];
if (fd < 0)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
FD_CLR((of_socket_t)fd, &_readFDs);
}
- (void)OF_removeObjectForWriting: (id <OFReadyForWritingObserving>)object
- (void)of_removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
/* TODO: Adjust _maxFD */
int fd = [object fileDescriptorForWriting];
if (fd < 0)
@throw [OFOutOfRangeException exception];
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
-
+
-
+
|
id const *objects;
fd_set readFDs;
fd_set writeFDs;
struct timeval timeout;
int events;
size_t count;
[self OF_processQueue];
[self of_processQueue];
if ([self OF_processReadBuffers])
if ([self of_processReadBuffers])
return;
#ifdef FD_COPY
FD_COPY(&_readFDs, &readFDs);
FD_COPY(&_writeFDs, &writeFDs);
#else
readFDs = _readFDs;
|