Skip to content

Document buffering behaviour fot Stdout(Lock) #137628

Open
@bertptrs

Description

@bertptrs

Location

Summary

The handles provided by std::io::stdout() are line-buffered, but there is nothing in the documentation suggesting this. The only mention of buffering for stdout in the documentation is the line

Each handle shares a global buffer of data to be written to the standard output stream. Access is also synchronized via a lock and explicit control over locking is available via the lock method.

I don't think this is very clear that stdout is buffered from this, nor that it uses line buffering.

Moreover, the comments for LineWriterShim suggest that this mechanism can be used to alternate between line buffering and block buffering for Stdout, which isn't mentioned in the documentation for Stdout at all.

I do not mean to relitigate whether or not it should be buffered (previous discussion in #23818) but I'd like to clarify how it is buffered, and how one should deal with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`T-libsRelevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions