Overview
Comment: | Add -[streamDidReceiveException:] to OFStreamObserverDelegate. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b5da54000db755d925818202054d23e9 |
User & Date: | js on 2010-10-24 12:54:28 |
Other Links: | manifest | tags |
Context
2010-10-24
| ||
13:15 | Rename a few methods returning BOOL. check-in: b6a39dd3d1 user: js tags: trunk | |
12:54 | Add -[streamDidReceiveException:] to OFStreamObserverDelegate. check-in: b5da54000d user: js tags: trunk | |
2010-10-21
| ||
20:01 | Make sure Jenkins' hash always interprets the byte as unsigned. check-in: 2552db2c1c user: js tags: trunk | |
Changes
Modified src/OFStreamObserver.h from [572eeb8e96] to [ef35b95705].
︙ | ︙ | |||
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 73 | /** * This callback is called when a stream did get ready for writing. * * \param stream The stream which did become ready for writing */ - (void)streamDidBecomeReadyForWriting: (OFStream*)stream; @end /** * \brief A class that can observe multiple streams at once. */ @interface OFStreamObserver: OFObject { OFMutableArray *readStreams; OFMutableArray *writeStreams; id <OFStreamObserverDelegate> delegate; #ifdef OF_HAVE_POLL OFDataArray *fds; OFMutableDictionary *fdToStream; #else fd_set readfds; fd_set writefds; int nfds; #endif } #ifdef OF_HAVE_PROPERTIES @property (retain) id <OFStreamObserverDelegate> delegate; #endif | > > > > > > > > | 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 73 74 75 76 77 78 79 80 81 | /** * This callback is called when a stream did get ready for writing. * * \param stream The stream which did become ready for writing */ - (void)streamDidBecomeReadyForWriting: (OFStream*)stream; /** * This callback is called when an exception occurred on the stream. * * \param stream The stream on which an exception occurred */ - (void)streamDidReceiveException: (OFStream*)stream; @end /** * \brief A class that can observe multiple streams at once. */ @interface OFStreamObserver: OFObject { OFMutableArray *readStreams; OFMutableArray *writeStreams; id <OFStreamObserverDelegate> delegate; #ifdef OF_HAVE_POLL OFDataArray *fds; OFMutableDictionary *fdToStream; #else fd_set readfds; fd_set writefds; fd_set exceptfds; int nfds; #endif } #ifdef OF_HAVE_PROPERTIES @property (retain) id <OFStreamObserverDelegate> delegate; #endif |
︙ | ︙ |
Modified src/OFStreamObserver.m from [18e0a8da0a] to [3a6498e60a].
︙ | ︙ | |||
94 95 96 97 98 99 100 | fds_c[i].events |= events; found = YES; } } if (!found) { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; | | | | 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 | fds_c[i].events |= events; found = YES; } } if (!found) { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; struct pollfd p = { fd, events | POLLERR, 0 }; [fds addItem: &p]; [fdToStream setObject: stream forKey: [OFNumber numberWithInt: fd]]; [pool release]; } } - (void)_removeStream: (OFStream*)stream withEvents: (short)events { struct pollfd *fds_c = [fds cArray]; size_t i, nfds = [fds count]; int fd = [stream fileDescriptor]; for (i = 0; i < nfds; i++) { if (fds_c[i].fd == fd) { OFAutoreleasePool *pool; fds_c[i].events &= ~events; if ((fds_c[i].events & ~POLLERR) != 0) return; pool = [[OFAutoreleasePool alloc] init]; [fds removeItemAtIndex: i]; [fdToStream removeObjectForKey: [OFNumber numberWithInt: fd]]; |
︙ | ︙ | |||
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 | OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; int fd = [stream fileDescriptor]; if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException newWithClass: isa]; FD_SET(fd, fdset); if (fd >= nfds) nfds = fd + 1; [pool release]; } - (void)_removeStream: (OFStream*)stream withFDSet: (fd_set*)fdset { int fd = [stream fileDescriptor]; if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException newWithClass: isa]; FD_CLR(fd, fdset); } #endif - (void)addStreamToObserveForReading: (OFStream*)stream { [readStreams addObject: stream]; | > > > > > | 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 | OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; int fd = [stream fileDescriptor]; if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException newWithClass: isa]; FD_SET(fd, fdset); FD_SET(fd, &exceptfds); if (fd >= nfds) nfds = fd + 1; [pool release]; } - (void)_removeStream: (OFStream*)stream withFDSet: (fd_set*)fdset otherFDSet: (fd_set*)other_fdset { int fd = [stream fileDescriptor]; if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException newWithClass: isa]; FD_CLR(fd, fdset); if (!FD_ISSET(fd, other_fdset)) FD_CLR(fd, &exceptfds); } #endif - (void)addStreamToObserveForReading: (OFStream*)stream { [readStreams addObject: stream]; |
︙ | ︙ | |||
193 194 195 196 197 198 199 | [readStreams removeObjectIdenticalTo: stream]; #ifdef OF_HAVE_POLL [self _removeStream: stream withEvents: POLLIN]; #else [self _removeStream: stream | | > | > | 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 | [readStreams removeObjectIdenticalTo: stream]; #ifdef OF_HAVE_POLL [self _removeStream: stream withEvents: POLLIN]; #else [self _removeStream: stream withFDSet: &readfds otherFDSet: &writefds]; #endif } - (void)removeStreamToObserveForWriting: (OFStream*)stream { [writeStreams removeObjectIdenticalTo: stream]; #ifdef OF_HAVE_POLL [self _removeStream: stream withEvents: POLLOUT]; #else [self _removeStream: stream withFDSet: &writefds otherFDSet: &readfds]; #endif } - (void)observe { [self observeWithTimeout: -1]; } |
︙ | ︙ | |||
271 272 273 274 275 276 277 278 279 | stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; } fds_c[i].revents = 0; } #else readfds_ = readfds; writefds_ = writefds; | > > > > > | > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; } fds_c[i].revents = 0; } #else # ifdef FD_COPY FD_COPY(readfds, readfds_); FD_COPY(writefds, writefds_); FD_COPY(exceptfds, exceptfds_); # else readfds_ = readfds; writefds_ = writefds; exceptfds_ = exceptfds; # endif if (select(nfds, &readfds_, &writefds_, &exceptfds_, (timeout != -1 ? &tv : NULL)) < 1) return NO; for (i = 0; i < count; i++) { int fd = [cArray[i] fileDescriptor]; |
︙ | ︙ | |||
311 312 313 314 315 316 317 318 | - (void)streamDidBecomeReadyForReading: (OFStream*)stream { } - (void)streamDidBecomeReadyForWriting: (OFStream*)stream { } @end | > > > > | 324 325 326 327 328 329 330 331 332 333 334 335 | - (void)streamDidBecomeReadyForReading: (OFStream*)stream { } - (void)streamDidBecomeReadyForWriting: (OFStream*)stream { } - (void)streamDidReceiveException: (OFStream*)stream { } @end |