savi-lang / TCP

TCP networking implementation for the Savi standard library.
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Deprecate the `TCP.Engine.pending_reads` method. #17

Closed jemc closed 1 year ago

jemc commented 1 year ago

There's no need for this method anymore. Loading pending reads into the read stream will now be handled automatically by the TCP engine, which will yield an IO.Action.Read action for each time a pending read is completed.

So you can just remove this function call from your code and de-indent the body of your yield block, such that it becomes part of the outer code. If you need to know the number of bytes available, then you can call io.read_stream.bytes_ahead_of_marker to find out.

For now, calling it will do nothing but yield once with the value of io.read_stream.bytes_ahead_of_marker to maintain compatibility. But the method will be removed soon.


There's no reason why the library user needs to be the one to tell the engine to handle pending reads - it was a bad design from the start, but it also turns out to be a blocker for Windows support, wherein pending reads will work a bit differently. Also it was inconsistent with the StdIn library which doesn't have this method in its engine, so that's also cleared up now.

jemc commented 1 year ago

FYI, @mneumann - I know you're using this in your MQTT library. You no longer need to call this method - your code will "just work" by simply removing it as described above.

However for now it's only deprecated - not removed; so for the time being your code will continue to work until the method is properly removed.

mneumann commented 1 year ago

@jemc Thanks for pointing this out. I will change the code accordingly once you release an updated version of TCP.

jemc commented 1 year ago

@mneumann - Released!