Differences From Artifact [f327edb513]:
- File src/OFRunLoop+Private.h — part of check-in [cf93ca4b21] at 2018-09-24 22:14:08 on branch trunk — OFStream: Allow specifying the run loop mode (user: js, size: 4800) [annotate] [blame] [check-ins using]
To Artifact [02b97312cb]:
- File
src/OFRunLoop+Private.h
— part of check-in
[d16ad96cbd]
at
2018-12-07 01:33:47
on branch trunk
— OFStream: Use a delegate for async operations
The target / selector approach had several drawbacks:
* It was inconvenient to use, as for every read or write, a target,
selector and context would need to be specified.
* It lacked any kind of type-safety and would not even warn about using
a callback method with the wrong number of parameters.
* It encouraged using a different callback method for each read or
write call, which results in code that is hard to follow and also
slower (as it needs to recreate the async operation with a new
callback every time). (user: js, size: 4630) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
30 31 32 33 34 35 36 | + (void)of_setMainRunLoop: (OFRunLoop *)runLoop; #ifdef OF_HAVE_SOCKETS + (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *) stream buffer: (void *)buffer length: (size_t)length mode: (of_run_loop_mode_t)mode | | < < | < < | < < | < < | 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 | + (void)of_setMainRunLoop: (OFRunLoop *)runLoop; #ifdef OF_HAVE_SOCKETS + (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *) stream buffer: (void *)buffer length: (size_t)length mode: (of_run_loop_mode_t)mode delegate: (id <OFStreamDelegate>)delegate; + (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *) stream buffer: (void *)buffer exactLength: (size_t)length mode: (of_run_loop_mode_t)mode delegate: (id <OFStreamDelegate>)delegate; + (void)of_addAsyncReadLineForStream: (OFStream <OFReadyForReadingObserving> *) stream encoding: (of_string_encoding_t)encoding mode: (of_run_loop_mode_t)mode delegate: (id <OFStreamDelegate>)delegate; + (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *) stream buffer: (const void *)buffer length: (size_t)length mode: (of_run_loop_mode_t)mode delegate: (id <OFStreamDelegate>)delegate; + (void)of_addAsyncConnectForTCPSocket: (OFTCPSocket *)socket mode: (of_run_loop_mode_t)mode target: (id)target selector: (SEL)selector context: (nullable id)context; + (void)of_addAsyncAcceptForTCPSocket: (OFTCPSocket *)socket mode: (of_run_loop_mode_t)mode |
︙ | ︙ |