Overview
Comment: | Return a bool from async write handlers
This allows performing another write with the same buffer, length and |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
47db5636d70a9536b9313bfada07b0a6 |
User & Date: | js on 2017-09-24 13:15:54 |
Other Links: | manifest | tags |
Context
2017-09-24
| ||
13:31 | OFHTTPClient: Use asynchronous writes check-in: 502a688f3d user: js tags: trunk | |
13:15 | Return a bool from async write handlers check-in: 47db5636d7 user: js tags: trunk | |
12:24 | OFStream: Add support for async writes check-in: 481225349f user: js tags: trunk | |
Changes
Modified src/OFRunLoop.m from [9b934c5330] to [8ab72d20c1].
︙ | ︙ | |||
282 283 284 285 286 287 288 | _writtenLength += length; if (_writtenLength != _length && exception == nil) return true; # ifdef OF_HAVE_BLOCKS | | | > > > > | | | | | > > > > < < | 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 | _writtenLength += length; if (_writtenLength != _length && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) { if (!_block(object, _buffer, _writtenLength, exception)) return false; _writtenLength = 0; return true; } else { # endif bool (*func)(id, SEL, OFStream *, const void *, size_t, id, id) = (bool (*)(id, SEL, OFStream *, const void *, size_t, id, id))[_target methodForSelector: _selector]; if (!func(_target, _selector, object, _buffer, _writtenLength, _context, exception)) return false; _writtenLength = 0; return true; # ifdef OF_HAVE_BLOCKS } # endif } - (void)dealloc { [_block release]; [super dealloc]; |
︙ | ︙ |
Modified src/OFStream.h from [2480f89bb9] to [7472119df2].
︙ | ︙ | |||
67 68 69 70 71 72 73 74 | * @brief A block which is called when data was written to the stream. * * @param stream The stream to which data was written * @param buffer The buffer which was written to the stream * @param length The length of the data that bas been written * @param exception An exception which occurred while reading or `nil` on * success */ | > > | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | * @brief A block which is called when data was written to the stream. * * @param stream The stream to which data was written * @param buffer The buffer which was written to the stream * @param length The length of the data that bas been written * @param exception An exception which occurred while reading or `nil` on * success * @return A bool whether another write with the same buffer, length and * callback block should be performed */ typedef bool (^of_stream_async_write_block_t)(OFStream *stream, const void *buffer, size_t length, id _Nullable exception); #endif /*! * @class OFStream OFStream.h ObjFW/OFStream.h * * @brief A base class for different types of streams. |
︙ | ︙ | |||
800 801 802 803 804 805 806 | * * @note The stream must implement @ref fileDescriptorForWriting and return a * valid file descriptor in order for this to work! * * @param buffer The buffer from which the data is written into the stream. The * buffer needs to be valid until the write request is completed! * @param length The length of the data that should be written | | | > > | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | * * @note The stream must implement @ref fileDescriptorForWriting and return a * valid file descriptor in order for this to work! * * @param buffer The buffer from which the data is written into the stream. The * buffer needs to be valid until the write request is completed! * @param length The length of the data that should be written * @param target The target on which the selector should be called when the * data has been received. If the method returns true, the same * buffer and length will be written again and same method will * be called again. * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, const void *buffer, size_t length, * id context, id exception)`. */ - (void)asyncWriteBuffer: (const void *)buffer length: (size_t)length target: (id)target selector: (SEL)selector context: (nullable id)context; |
︙ | ︙ |