Overview
Comment: | OFStreamObserver: Add -[cancel]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
acb65988562539def0653ca6279182c3 |
User & Date: | js on 2012-09-12 06:00:29 |
Original User & Date: | js on 2012-09-12 06:00:30 |
Other Links: | manifest | tags |
Context
2012-09-12
| ||
06:00 | OFStreamObserver: Cancel is no event anymore. check-in: 3de549d6a5 user: js tags: trunk | |
06:00 | OFStreamObserver: Add -[cancel]. check-in: acb6598856 user: js tags: trunk | |
06:00 | OFStreamObserver: Take a double as timeout. check-in: 3c99aa51da user: js tags: trunk | |
Changes
Modified src/OFStreamObserver.h from [8202cb76d9] to [a4947834b1].
︙ | ︙ | |||
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | * timeout is reached. * * \param timeout The time to wait for an event, in seconds * \return A boolean whether events occurred during the timeinterval */ - (BOOL)observeWithTimeout: (double)timeout; - (void)_addFileDescriptorForReading: (int)fd; - (void)_addFileDescriptorForWriting: (int)fd; - (void)_removeFileDescriptorForReading: (int)fd; - (void)_removeFileDescriptorForWriting: (int)fd; - (void)_processQueue; - (BOOL)_processCache; @end @interface OFObject (OFStreamObserverDelegate) <OFStreamObserverDelegate> @end | > > > > > > > > > | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | * timeout is reached. * * \param timeout The time to wait for an event, in seconds * \return A boolean whether events occurred during the timeinterval */ - (BOOL)observeWithTimeout: (double)timeout; /** * \brief Cancels the currently blocking observe call. * * This is automatically done when a new stream is added or removed by another * thread, but in some circumstances, it might be desirable for a thread to * manually stop the observe running in another thread. */ - (void)cancel; - (void)_addFileDescriptorForReading: (int)fd; - (void)_addFileDescriptorForWriting: (int)fd; - (void)_removeFileDescriptorForReading: (int)fd; - (void)_removeFileDescriptorForWriting: (int)fd; - (void)_processQueue; - (BOOL)_processCache; @end @interface OFObject (OFStreamObserverDelegate) <OFStreamObserverDelegate> @end |
Modified src/OFStreamObserver.m from [f07f85b2a0] to [2620dc6f33].
︙ | ︙ | |||
194 195 196 197 198 199 200 | [queue addObject: stream]; [queueInfo addItem: &qi]; [queueFDs addItem: &fd]; } @finally { [mutex unlock]; } | < < < < | < < < < < | < | 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 | [queue addObject: stream]; [queueInfo addItem: &qi]; [queueFDs addItem: &fd]; } @finally { [mutex unlock]; } [self cancel]; } - (void)addStreamForWriting: (OFStream*)stream { [mutex lock]; @try { int qi = QUEUE_ADD | QUEUE_WRITE; int fd = [stream fileDescriptor]; [queue addObject: stream]; [queueInfo addItem: &qi]; [queueFDs addItem: &fd]; } @finally { [mutex unlock]; } [self cancel]; } - (void)removeStreamForReading: (OFStream*)stream { [mutex lock]; @try { int qi = QUEUE_REMOVE | QUEUE_READ; |
︙ | ︙ | |||
371 372 373 374 375 376 377 378 379 380 381 382 383 384 | } - (BOOL)observeWithTimeout: (double)timeout { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (BOOL)_processCache { OFStream **objects = [readStreams objects]; size_t i, count = [readStreams count]; BOOL foundInCache = NO; | > > > > > > > > > > | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | } - (BOOL)observeWithTimeout: (double)timeout { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (void)cancel { #ifndef _WIN32 OF_ENSURE(write(cancelFD[1], "", 1) > 0); #else OF_ENSURE(sendto(cancelFD[1], "", 1, 0, (struct sockaddr*)&cancelAddr, sizeof(cancelAddr)) > 0); #endif } - (BOOL)_processCache { OFStream **objects = [readStreams objects]; size_t i, count = [readStreams count]; BOOL foundInCache = NO; |
︙ | ︙ |