Skip to content
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

Support flush() on ostream. #2435

Closed
pikapi12321 opened this issue Jul 26, 2021 · 7 comments
Closed

Support flush() on ostream. #2435

pikapi12321 opened this issue Jul 26, 2021 · 7 comments

Comments

@pikapi12321
Copy link

I noticed that flush() is a private member of ostream and cannot be called outside. I don't understand why it is designed to be private.

@vitaut
Copy link
Contributor

vitaut commented Jul 26, 2021

A PR to make flush public is welcome.

@vitaut
Copy link
Contributor

vitaut commented Jul 30, 2021

Made flush public in bba0a9d. Thanks for the suggestion.

@vitaut vitaut closed this as completed Jul 30, 2021
@pikapi12321
Copy link
Author

Made flush public in bba0a9d. Thanks for the suggestion.

I've tried public flush() in my project's logger. It seems that flush() is not safe if another thread is constantly calling ostream::print() on the same ostream object. My debug build ran ok while my release build encountered segmentation fault. Problem went away after I removed my flushes.

@vitaut
Copy link
Contributor

vitaut commented Aug 2, 2021

ostream is not thread-safe as mentioned in the docs: https://fmt.dev/latest/api.html#os-api. If you want to write from multiple threads you should use a different API or add synchronization.

@bl-ue
Copy link

bl-ue commented Oct 16, 2021

Hey @vitaut! v8.0.1 was released a month before this feature...will you please consider cutting a new release?

@bl-ue
Copy link

bl-ue commented Oct 16, 2021

In the meantime, do you know of any way to flush the stream?

@vitaut
Copy link
Contributor

vitaut commented Oct 16, 2021

This is too minor for a dedicated release and will be part of the regular release in a couple of months. In the meantime you can pin to the specific commit that adds flush or use the standard FILE API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants