Skip to content

What is a push? #9

@sunfishcode

Description

@sunfishcode

#4 introduces the concept of read returning a status, which can be ready, end, or push. The first two are fairly obvious, but push is a new concept, and is not fully defined yet.

It is similar in intent to the TCP PUSH flag. It means: go ahead and process the data that's been received so far, before trying to read more data. This avoids situations where data in a long pipeline gets stuck in the middle where something is waiting for more data to fill up a buffer before sending it through.

In theory we could return push when a TCP push is received, except the host OS APIs we'll implement this with don't expose the PUSH flag in a way that supports this:

  • On the sending side PUSH is implicitly set after each send and there is no flush function, so there's no way to tell the difference between a send which needs to be pushed and one which will be immediately followed by more data anyway.
  • On the receiving side, PUSH is not reported explicitly, and there's no way to tell the difference between a read which ended in a PUSH and one which ended for other reasons.

A push is not meant to be semantically relevant. Programs generally shouldn't behave differently if their input comes from a user typing in text on a line-oriented terminal, which might send pushes at each newline, or reading from a file, which might not.

A particular open question is, how do pushes interact with errors? #4 proposes that read defer errors so that when an error is returned, there's nothing left for user code to do and it can just fail immediately. To make sure user code doesn't worry about pending buffered data, it specifies a push once the remaining data is read, before reporting the error. However, it's not yet clear whether this is a good design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions