|
51 | 51 | // This allows the listener to keep an accurate count of how many
|
52 | 52 | // connections have been opened so far.
|
53 | 53 | try @_listener.as!(IO.Actor(IO.Action)).io_deferred_action(IO.Action.ClosedChild)
|
54 |
| - |
55 |
| - // TODO: windows complete writes, flush-after-mute (pending writes logic from Pony) |
56 |
| - // | IO.Action.Write | |
57 |
| - // ... |
| 54 | + yield action |
| 55 | + |
| 56 | + | IO.Action.Read | |
| 57 | + if Platform.is_windows ( |
| 58 | + None // TODO: @_windows_complete_reads(arg) |
| 59 | + | |
| 60 | + @_pending_reads_unix -> (yield action) |
| 61 | + ) |
| 62 | + |
| 63 | + // TODO: windows complete writes, flush-after-mute (pending writes logic from Pony) |
| 64 | + // | IO.Action.Write | |
| 65 | + // ... |
| 66 | + | |
| 67 | + yield action |
58 | 68 | )
|
59 |
| - yield action |
60 | 69 | )
|
61 | 70 | @
|
62 | 71 |
|
|
67 | 76 | :fun ref flush!
|
68 | 77 | @write_stream.flush!
|
69 | 78 |
|
| 79 | + // TODO: Remove this deprecated method. |
| 80 | + :: DEPRECATED: There's no need for this method anymore. |
| 81 | + :: Loading pending reads into the read stream will now be handled |
| 82 | + :: automatically by the TCP engine, which will yield an `IO.Action.Read` |
| 83 | + :: action for each time a pending read is completed. |
| 84 | + :: |
| 85 | + :: So you can just remove this function call from your code and de-indent |
| 86 | + :: the body of your yield block, such that it becomes part of the outer code. |
| 87 | + :: If you need to know the number of bytes available, then you can call |
| 88 | + :: `io.read_stream.bytes_ahead_of_marker` to find out. |
70 | 89 | :fun ref pending_reads
|
71 | 90 | :yields USize for None
|
72 |
| - if Platform.is_windows ( |
73 |
| - None // TODO: @_windows_complete_reads(arg) |
74 |
| - | |
75 |
| - @_pending_reads_unix -> (bytes_available | yield bytes_available) |
76 |
| - ) |
| 91 | + yield @read_stream.bytes_ahead_of_marker |
77 | 92 | @
|
78 | 93 |
|
79 | 94 | :fun ref _pending_reads_unix None
|
80 |
| - :yields USize for None |
| 95 | + :yields None for None |
81 | 96 | while @io.is_readable (
|
82 | 97 | try (
|
83 | 98 | bytes_read = @read_stream.receive_from!(@io)
|
84 |
| - if (bytes_read > 0) (yield @read_stream.bytes_ahead_of_marker) |
| 99 | + if (bytes_read > 0) (yield None) |
85 | 100 | )
|
86 | 101 | )
|
87 | 102 |
|
|
0 commit comments