Differences From Artifact [864995cc48]:
- File
src/OFStreamObserver.m
— part of check-in
[a61ab37726]
at
2011-04-01 22:14:32
on branch trunk
— Cancel the currently blocking -[observe] when the stream set is changed.
Not working on win32 yet, it will be ported to it later as it's not that
easy there, since select() can only observe sockets. (user: js, size: 10141) [annotate] [blame] [check-ins using]
To Artifact [9e9e13990f]:
- File src/OFStreamObserver.m — part of check-in [321274075d] at 2011-04-02 02:29:56 on branch trunk — Fix small bugs introduced by the last commit. (user: js, size: 10245) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | } - init { self = [super init]; @try { struct pollfd p = { 0, POLLIN, 0 }; readStreams = [[OFMutableArray alloc] init]; writeStreams = [[OFMutableArray alloc] init]; queue = [[OFMutableArray alloc] init]; queueInfo = [[OFMutableArray alloc] init]; #ifdef OF_HAVE_POLL fds = [[OFDataArray alloc] initWithItemSize: | > > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | } - init { self = [super init]; @try { #ifdef OF_HAVE_POLL struct pollfd p = { 0, POLLIN, 0 }; #endif readStreams = [[OFMutableArray alloc] init]; writeStreams = [[OFMutableArray alloc] init]; queue = [[OFMutableArray alloc] init]; queueInfo = [[OFMutableArray alloc] init]; #ifdef OF_HAVE_POLL fds = [[OFDataArray alloc] initWithItemSize: |
︙ | ︙ | |||
76 77 78 79 80 81 82 | @throw [OFInitializationFailedException newWithClass: isa]; #ifdef OF_HAVE_POLL p.fd = cancelFd[0]; [fds addItem: &p]; #else | | > > > | 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 | @throw [OFInitializationFailedException newWithClass: isa]; #ifdef OF_HAVE_POLL p.fd = cancelFd[0]; [fds addItem: &p]; #else FD_SET(cancelFd[0], &readfds); nfds = cancelFd[0] + 1; #endif } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { close(cancelFd[0]); close(cancelFd[1]); [(id)delegate release]; [readStreams release]; [writeStreams release]; [queue release]; [queueInfo release]; #ifdef OF_HAVE_POLL [fdToStream release]; |
︙ | ︙ | |||
379 380 381 382 383 384 385 | if (poll(fds_c, (nfds_t)nfds, timeout) < 1) return NO; for (i = 0; i < nfds; i++) { OFNumber *num; OFStream *stream; | > | | | > | | < | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | if (poll(fds_c, (nfds_t)nfds, timeout) < 1) return NO; for (i = 0; i < nfds; i++) { OFNumber *num; OFStream *stream; if (fds_c[i].revents & POLLIN) { if (fds_c[i].fd == cancelFd[0]) { char buf; read(cancelFd[0], &buf, 1); fds_c[i].revents = 0; continue; } num = [OFNumber numberWithInt: fds_c[i].fd]; stream = [fdToStream objectForKey: num]; [delegate streamDidBecomeReadyForReading: stream]; [pool releaseObjects]; } if (fds_c[i].revents & POLLOUT) { |
︙ | ︙ |