Differences From Artifact [17f5ac1ccb]:
- File
src/OFStreamObserver_poll.m
— part of check-in
[417b213d41]
at
2012-07-16 23:49:50
on branch trunk
— Add OF_ENSURE.
This is to be used when the condition includes a statement that needs to
be executed, as with assert, this would not be executed anymore when
NDEBUG is defined. (user: js, size: 3496) [annotate] [blame] [check-ins using]
To Artifact [a6a3da0735]:
- File
src/OFStreamObserver_poll.m
— part of check-in
[1255f3a11a]
at
2012-08-10 20:08:24
on branch trunk
— Directly use the runtime's autorelease pools.
This greatly improves performance, as it gets rid of the overhead of
OFAutoreleasePool. (user: js, size: 3507) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
19 20 21 22 23 24 25 | #define __NO_EXT_QNX #include <unistd.h> #include <poll.h> #import "OFStreamObserver_poll.h" #import "OFDataArray.h" | < > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #define __NO_EXT_QNX #include <unistd.h> #include <poll.h> #import "OFStreamObserver_poll.h" #import "OFDataArray.h" #import "OFOutOfRangeException.h" #import "autorelease.h" #import "macros.h" @implementation OFStreamObserver_poll - init { self = [super init]; |
︙ | ︙ | |||
118 119 120 121 122 123 124 | { [self _removeFileDescriptor: fd withEvents: POLLOUT]; } - (BOOL)observeWithTimeout: (int)timeout { | | | > > | < | < > > > < < < | > | < | 118 119 120 121 122 123 124 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 177 178 179 180 181 182 183 184 | { [self _removeFileDescriptor: fd withEvents: POLLOUT]; } - (BOOL)observeWithTimeout: (int)timeout { void *pool = objc_autoreleasePoolPush(); struct pollfd *FDsCArray; size_t i, nFDs; [self _processQueue]; if ([self _processCache]) { objc_autoreleasePoolPop(pool); return YES; } objc_autoreleasePoolPop(pool); FDsCArray = [FDs cArray]; nFDs = [FDs count]; #ifdef OPEN_MAX if (nFDs > OPEN_MAX) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #endif if (poll(FDsCArray, (nfds_t)nFDs, timeout) < 1) return NO; for (i = 0; i < nFDs; i++) { pool = objc_autoreleasePoolPush(); if (FDsCArray[i].revents & POLLIN) { if (FDsCArray[i].fd == cancelFD[0]) { char buffer; OF_ENSURE(read(cancelFD[0], &buffer, 1) > 0); FDsCArray[i].revents = 0; objc_autoreleasePoolPop(pool); continue; } [delegate streamIsReadyForReading: FDToStream[FDsCArray[i].fd]]; } if (FDsCArray[i].revents & POLLOUT) { [delegate streamIsReadyForWriting: FDToStream[FDsCArray[i].fd]]; } if (FDsCArray[i].revents & POLLERR) { [delegate streamDidReceiveException: FDToStream[FDsCArray[i].fd]]; } FDsCArray[i].revents = 0; objc_autoreleasePoolPop(pool); } return YES; } @end |