Overview
Comment: | Refactor OFKernelEventObserver |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bbe4040126690c1972fffbc7fa7c7008 |
User & Date: | js on 2015-05-04 20:34:57 |
Other Links: | manifest | tags |
Context
2015-05-04
| ||
22:54 | utils/ofhttp: Fix a type mismatch check-in: 0b13fb2e38 user: js tags: trunk | |
20:34 | Refactor OFKernelEventObserver check-in: bbe4040126 user: js tags: trunk | |
14:30 | Add OFKernelEventObserver_epoll check-in: ed4a6f396b user: js tags: trunk | |
Changes
Modified src/OFKernelEventObserver+Private.h from [eac8ac6f06] to [0257c37a21].
︙ | |||
13 14 15 16 17 18 19 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | - - - - + + + + | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFKernelEventObserver.h" @interface OFKernelEventObserver (OF_PRIVATE_CATEGORY) |
Modified src/OFKernelEventObserver.h from [2064104d5a] to [7a17ea14b6].
︙ | |||
106 107 108 109 110 111 112 | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | - - - + | * * @note Currently, Win32 can only observe TCP and UDP sockets! */ @interface OFKernelEventObserver: OFObject { OFMutableArray *_readObjects; OFMutableArray *_writeObjects; |
︙ |
Modified src/OFKernelEventObserver.m from [566a494d67] to [80d7681218].
︙ | |||
105 106 107 108 109 110 111 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | - + - | #if !defined(OF_HAVE_PIPE) && !defined(__wii__) socklen_t cancelAddrLen; #endif _readObjects = [[OFMutableArray alloc] init]; _writeObjects = [[OFMutableArray alloc] init]; _queue = [[OFMutableArray alloc] init]; |
︙ | |||
143 144 145 146 147 148 149 | 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 | - - - - - - - + | if (of_getsockname(_cancelFD[0], (struct sockaddr*)&_cancelAddr, &cancelAddrLen) != 0) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; # endif #endif |
︙ | |||
194 195 196 197 198 199 200 | 187 188 189 190 191 192 193 194 195 196 197 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 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | - - + - - - + - - - + - - - + - + + + + - + + - + - + - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - - + | - (void)addObjectForReading: (id <OFReadyForReadingObserving>)object { #ifdef OF_HAVE_THREADS [_mutex lock]; #endif @try { int qi = QUEUE_ADD | QUEUE_READ; |
︙ |
Modified src/OFKernelEventObserver_epoll.m from [b4f29b6ca3] to [463d24baf5].
︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 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 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 185 186 187 188 189 190 191 192 193 194 195 196 | + + + + + + - + + + - - - + + + - + - + + - - + + - + - + - - + + + - + - - + + + - + - - + + + - + - - + + + + | #include <sys/epoll.h> #import "OFKernelEventObserver.h" #import "OFKernelEventObserver+Private.h" #import "OFKernelEventObserver_epoll.h" #import "OFMapTable.h" #import "OFNull.h" #import "OFInitializationFailedException.h" #import "OFObserveFailedException.h" #define EVENTLIST_SIZE 64 static const of_map_table_functions_t mapFunctions = { NULL }; @implementation OFKernelEventObserver_epoll - init { self = [super init]; @try { struct epoll_event event; #ifdef HAVE_EPOLL_CREATE1 if ((_epfd = epoll_create1(EPOLL_CLOEXEC)) == -1) @throw [OFInitializationFailedException exception]; #else int flags; if ((_epfd = epoll_create(1)) == -1) @throw [OFInitializationFailedException exception]; if ((flags = fcntl(_epfd, F_GETFD, 0)) != -1) fcntl(_epfd, F_SETFD, flags | FD_CLOEXEC); #endif _FDToEvents = [[OFMapTable alloc] initWithKeyFunctions: mapFunctions valueFunctions: mapFunctions]; memset(&event, 0, sizeof(event)); event.events = EPOLLIN; event.data.ptr = [OFNull null]; |
︙ | |||
193 194 195 196 197 198 199 | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | - + - + - + | return [OFObserveFailedException exceptionWithObserver: self errNo: errno]; if (events == 0) return false; for (i = 0; i < events; i++) { |
︙ |
Modified src/OFKernelEventObserver_kqueue.m from [f6c09249b4] to [cfe0087621].
︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 41 42 43 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 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 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 | + + - + + - + - + + + + + + + + + + - + - + + + + + + + + + + - + - + + + - + + - + + + - + + | @implementation OFKernelEventObserver_kqueue - init { self = [super init]; @try { struct kevent event; #ifdef HAVE_KQUEUE1 if ((_kernelQueue = kqueue1(O_CLOEXEC)) == -1) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; #else int flags; if ((_kernelQueue = kqueue()) == -1) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; if ((flags = fcntl(_kernelQueue, F_GETFD, 0)) != -1) fcntl(_kernelQueue, F_SETFD, flags | FD_CLOEXEC); #endif _changeList = [[OFDataArray alloc] initWithItemSize: sizeof(struct kevent)]; |
︙ | |||
171 172 173 174 175 176 177 | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | - + - + | pool = objc_autoreleasePoolPush(); switch (eventList[i].filter) { case EVFILT_READ: if ([_delegate respondsToSelector: @selector(objectIsReadyForReading:)]) [_delegate objectIsReadyForReading: |
︙ |
Modified src/OFKernelEventObserver_poll.h from [e4ad4dce23] to [f1ee0351df].
︙ | |||
17 18 19 20 21 22 23 24 25 | 17 18 19 20 21 22 23 24 25 26 27 | + + | #import "OFKernelEventObserver.h" @class OFDataArray; @interface OFKernelEventObserver_poll: OFKernelEventObserver { OFDataArray *_FDs; size_t _maxFD; __unsafe_unretained id *_FDToObject; } @end |
Modified src/OFKernelEventObserver_poll.m from [87d84638ba] to [b1989e4bd7].
︙ | |||
41 42 43 44 45 46 47 | 41 42 43 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 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 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 | - + + - - + + + + - - + + + + + + + + + + + + - - + + - + + + + + - + + - + - - + + + - + - - + + + - + - - + + + - + - - + + + | @implementation OFKernelEventObserver_poll - init { self = [super init]; @try { |
︙ | |||
161 162 163 164 165 166 167 168 169 170 171 172 173 174 | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | + + + | @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; if (events == 0) return false; for (i = 0; i < nFDs; i++) { if (FDs[i].fd > _maxFD) @throw [OFOutOfRangeException exception]; if (FDs[i].revents & POLLIN) { if (FDs[i].fd == _cancelFD[0]) { char buffer; OF_ENSURE(read(_cancelFD[0], &buffer, 1) == 1); FDs[i].revents = 0; |
︙ |
Modified src/OFKernelEventObserver_select.h from [feec10ec31] to [ba6ed69d4a].
︙ | |||
26 27 28 29 30 31 32 33 34 | 26 27 28 29 30 31 32 33 34 35 | + | #endif #import "OFKernelEventObserver.h" @interface OFKernelEventObserver_select: OFKernelEventObserver { fd_set _readFDs, _writeFDs; int _maxFD; } @end |
Modified src/OFKernelEventObserver_select.m from [6084d13774] to [9c1fba606a].
︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 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 | + + + + + + + - + + + - - + + + + + + + + + + - - + + + + + + + + + + + + - - + + + + + + - - + + | #include <sys/time.h> #import "OFKernelEventObserver.h" #import "OFKernelEventObserver+Private.h" #import "OFKernelEventObserver_select.h" #import "OFArray.h" #import "OFInitializationFailedException.h" #import "OFObserveFailedException.h" #import "OFOutOfRangeException.h" #import "socket_helpers.h" @implementation OFKernelEventObserver_select - init { self = [super init]; #ifndef _WIN32 if (_cancelFD[0] >= FD_SETSIZE) @throw [OFInitializationFailedException exception]; #endif FD_ZERO(&_readFDs); FD_ZERO(&_writeFDs); FD_SET(_cancelFD[0], &_readFDs); |
︙ | |||
124 125 126 127 128 129 130 | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | - + | #ifndef _WIN32 timeout.tv_sec = (time_t)timeInterval; #else timeout.tv_sec = (long)timeInterval; #endif timeout.tv_usec = (int)lrint((timeInterval - timeout.tv_sec) * 1000); |
︙ |