Differences From Artifact [7472119df2]:
- File
src/OFStream.h
— part of check-in
[47db5636d7]
at
2017-09-24 13:15:54
on branch trunk
— Return a bool from async write handlers
This allows performing another write with the same buffer, length and
callback, which is useful for asynchronously writing in chunks. (user: js, size: 41700) [annotate] [blame] [check-ins using]
To Artifact [c63c26554d]:
- File src/OFStream.h — part of check-in [1084b23ef7] at 2017-09-24 15:13:55 on branch trunk — OFStream: More flexible repeating async writes (user: js, size: 42318) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
64 65 66 67 68 69 70 | OFString *_Nullable line, id _Nullable exception); /*! * @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 | | > > | > | | > | | 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 | OFString *_Nullable line, id _Nullable exception); /*! * @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 bytesWritten The number of bytes which have been written. This * matches the length specified on the asynchronous write * if no exception was encountered. * @param exception An exception which occurred while reading or `nil` on * success * @return The length to repeat the write with or 0 if it should not repeat. * The buffer may be changed, so that every time a new buffer and length * can be specified while the callback stays the same. */ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream, const void *_Nonnull *_Nonnull buffer, size_t bytesWritten, id _Nullable exception); #endif /*! * @class OFStream OFStream.h ObjFW/OFStream.h * * @brief A base class for different types of streams. * |
︙ | ︙ | |||
803 804 805 806 807 808 809 | * @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 | | > > | | | | | > > > > | 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | * @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 written. The method should return the length for * the next write with the same callback or 0 if it should not * repeat. The buffer may be changed, so that every time a new * buffer and length can be specified while the callback stays * the same. * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, const void *buffer, * size_t bytesWritten, id context, id exception)`. */ - (void)asyncWriteBuffer: (const void *)buffer length: (size_t)length target: (id)target selector: (SEL)selector context: (nullable id)context; # ifdef OF_HAVE_BLOCKS /*! * @brief Asynchronously writes a buffer into the stream. * * @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 block The block to call when the data has been written. It should * return the length for the next write with the same callback or * 0 if it should not repeat. The buffer may be changed, so that * every time a new buffer and length can be specified while the * callback stays the same. */ - (void)asyncWriteBuffer: (const void *)buffer length: (size_t)length block: (of_stream_async_write_block_t)block; # endif #endif |
︙ | ︙ |