Differences From Artifact [bf14750714]:
- File
src/OFStreamObserver.m
— part of check-in
[35aab77af3]
at
2011-04-01 16:54:57
on branch trunk
— Make OFStreamObserver thread-safe.
It does not cancel the currently running -[observe] yet when changing
the set of streams to observe. (user: js, size: 9282) [annotate] [blame] [check-ins using]
To Artifact [95f2f3be53]:
- File src/OFStreamObserver.m — part of check-in [61cad3ee76] at 2011-04-01 17:10:45 on branch trunk — Call -[releaseObjects] after calling the delegate. (user: js, size: 9508) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
329 330 331 332 333 334 335 336 337 338 339 340 341 342 | cArray = [readStreams cArray]; count = [readStreams count]; for (i = 0; i < count; i++) { if (cArray[i]->cache != NULL) { [delegate streamDidBecomeReadyForReading: cArray[i]]; foundInCache = YES; } } /* * As long as we have data in the cache for any stream, we don't want * to block. */ | > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | cArray = [readStreams cArray]; count = [readStreams count]; for (i = 0; i < count; i++) { if (cArray[i]->cache != NULL) { [delegate streamDidBecomeReadyForReading: cArray[i]]; foundInCache = YES; [pool releaseObjects]; } } /* * As long as we have data in the cache for any stream, we don't want * to block. */ |
︙ | ︙ | |||
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 | OFNumber *num; OFStream *stream; if (fds_c[i].revents & POLLIN) { num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; } if (fds_c[i].revents & POLLOUT) { num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; } if (fds_c[i].revents & POLLERR) { num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidReceiveException: stream]; } fds_c[i].revents = 0; } #else # ifdef FD_COPY FD_COPY(&readfds, &readfds_); | > > > | 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 | OFNumber *num; OFStream *stream; if (fds_c[i].revents & POLLIN) { num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; [pool releaseObjects]; } if (fds_c[i].revents & POLLOUT) { num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; [pool releaseObjects]; } if (fds_c[i].revents & POLLERR) { num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidReceiveException: stream]; [pool releaseObjects]; } fds_c[i].revents = 0; } #else # ifdef FD_COPY FD_COPY(&readfds, &readfds_); |
︙ | ︙ | |||
391 392 393 394 395 396 397 | if (select(nfds, &readfds_, &writefds_, &exceptfds_, (timeout != -1 ? &tv : NULL)) < 1) return NO; for (i = 0; i < count; i++) { int fd = [cArray[i] fileDescriptor]; | | > > > | > | > | > > | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | if (select(nfds, &readfds_, &writefds_, &exceptfds_, (timeout != -1 ? &tv : NULL)) < 1) return NO; for (i = 0; i < count; i++) { int fd = [cArray[i] fileDescriptor]; if (FD_ISSET(fd, &readfds_)) { [delegate streamDidBecomeReadyForReading: cArray[i]]; [pool releaseObjects]; } if (FD_ISSET(fd, &exceptfds_)) { [delegate streamDidReceiveException: cArray[i]]; [pool releaseObjects]; /* * Prevent calling it twice in case the fd is in both * sets. */ FD_CLR(fd, &exceptfds_); } } cArray = [writeStreams cArray]; count = [writeStreams count]; for (i = 0; i < count; i++) { int fd = [cArray[i] fileDescriptor]; if (FD_ISSET(fd, &writefds_)) { [delegate streamDidBecomeReadyForWriting: cArray[i]]; [pool releaseObjects]; } if (FD_ISSET(fd, &exceptfds_)) { [delegate streamDidReceiveException: cArray[i]]; [pool releaseObjects]; } } #endif [pool release]; return YES; } |
︙ | ︙ |