-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Future version of depleted
#13
Comments
Yeah, I did some really wacky stuff with that for node: https://github.com/haxetink/tink_tcp/blob/pure/src/tink/tcp/nodejs/NodejsConnector.hx#L25 In hindsight I wonder whether that doesn't complicate things. I think that basically the socket should be closed from your end when you end your outgoing stream. When you don't want the incoming stream to stop, don't end the outgoing one (all of which is the handler's responsibility). Nice and clean. No allowHalfOpen and other weirdness. That said, it has two issues:
Let's think about this. This exterior observation of internal state change doesn't fit too well with the idea of these streams that try really hard to pretend they are pure ^^ I wonder though: can you think of other applications for this? It's kind of special about TCP that you have two so strongly couple streams. |
I dunno, this is mainly because tcp handler's definition doesn't seem to fit well on blocking targets. Because it is I realize my proposal here won't fix the problem either. |
Hmm. I think being blocking or not should not be that important. In theory One of the problems right now is that if you set a socket to be non-blocking without runloop, then it runs into a stack overflow with empty chunks. |
With haxetink/tink_tcp#5 we probably don't need |
Currently
depleted
is aBool
value indicating the current stream is depleted. So essentially only anEmpty
and its derivatives (Future, Compound, etc) will havedepleted = true
. (Or it should be more accurately named asisEmpty
...)While that is useful for code which iterates the stream, it isn't very useful for code that "observe" the stream. So I would like to suggest adding a property of type
Future<Outcome<Noise, Error>>
which when happens it means that "the stream's end has been observed". or in other words we can now iterate it in a sync manner.This is different from iterating the stream myself and handle the result. Because the proposed future remains lazy until "someone else" iterates the stream to an end.
I think of this idea when I was trying to find the right moment to close the socket in tink_tcp.
The text was updated successfully, but these errors were encountered: