Differences From Artifact [4a4c51ed64]:
- File
src/OFKernelEventObserver_poll.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 4563) [annotate] [blame] [check-ins using]
To Artifact [bb3d801549]:
- File src/OFKernelEventObserver_poll.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 4575) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
71 72 73 74 75 76 77 | } - (void)OF_addObject: (id)object fileDescriptor: (int)fd events: (short)events { struct pollfd *FDs = [_FDs items]; | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | } - (void)OF_addObject: (id)object fileDescriptor: (int)fd events: (short)events { struct pollfd *FDs = [_FDs items]; size_t count = [_FDs count]; bool found = false; for (size_t i = 0; i < count; i++) { if (FDs[i].fd == fd) { FDs[i].events |= events; found = true; break; } } |
︙ | ︙ | |||
102 103 104 105 106 107 108 | } - (void)OF_removeObject: (id)object fileDescriptor: (int)fd events: (short)events { struct pollfd *FDs = [_FDs items]; | | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | } - (void)OF_removeObject: (id)object fileDescriptor: (int)fd events: (short)events { struct pollfd *FDs = [_FDs items]; size_t nFDs = [_FDs count]; for (size_t i = 0; i < nFDs; i++) { if (FDs[i].fd == fd) { FDs[i].events &= ~events; if (FDs[i].events == 0) { /* * TODO: Remove from and resize _FDToObject, * adjust _maxFD. |
︙ | ︙ | |||
158 159 160 161 162 163 164 | } - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { void *pool = objc_autoreleasePoolPush(); struct pollfd *FDs; int events; | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | } - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { void *pool = objc_autoreleasePoolPush(); struct pollfd *FDs; int events; size_t nFDs; [self OF_processQueue]; [self OF_processReadBuffers]; objc_autoreleasePoolPop(pool); FDs = [_FDs items]; |
︙ | ︙ | |||
180 181 182 183 184 185 186 | events = poll(FDs, (nfds_t)nFDs, (int)(timeInterval != -1 ? timeInterval * 1000 : -1)); if (events < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; | | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | events = poll(FDs, (nfds_t)nFDs, (int)(timeInterval != -1 ? timeInterval * 1000 : -1)); if (events < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; for (size_t i = 0; i < nFDs; i++) { assert(FDs[i].fd <= _maxFD); if (FDs[i].revents & POLLIN) { if (FDs[i].fd == _cancelFD[0]) { char buffer; #ifdef OF_HAVE_PIPE |
︙ | ︙ |